Hey everybody, I'm having a small problem:
Truncating long Windows filenames to DOS-compilant 8+3 filenames is easy, as long as you don't have more than 4 similar files - take the first 6 characters, add ~1(2,3,4) plus the extension and you're done.
So far, so good.
My problem right now is Window's way of truncating the filenames when you have more than four similar files, since then, starting with the 5th file, Windows takes only the first two letters and then adds some sort of hash (4 characters long) and the ~1 to it, it doesn't just increment the number at the end like with the first four.
Now, Windows comes with a handy little function called GetShortFileName you can use to generate the 8+3 name of an existing file, but you can't use it to generate the 8+3 name of a file that doesn't exist on your harddisk, if you call it with a non-existing path as the argument, it just returns.
So you can see where this is going, does anyone know how this "hash" is generated?
Microsoft itself is pretty quiet about that, all I could find is a short paragraph in an MSPress book ([LINK]), but that just states that it is done the way I described it, it doesn't explain how that hash is generated, which is what I'm interested in :/
And that's it, I'm at a loss what to do, so any help is really appreciated.
If you want to check for yourself, create 5 Files with similar names (LongFileNameOne.txt, LongFileNameTwo.txt, etc.), then do a "dir /x" and watch the result.