I am trying to get the 8.3 (short) filename of a long (standard) filename, because an old program that we are still using uses those short filenames. For some reason that I can not figure out, the following program is not working :
Each time, I get the following output in my write file :
C:\Documents and Settings\STUDENT\My Documents\Dominique\CLS\July 2011\FBPMe-b\Analyse\fbpme-b_1xx\fbpme-b_104.txt
ÿÿÿ
0.000000
0
Which indicates that the GetShortPathName did not work, since it returned 0 and weird characters instead of the short filename. The filepath is OK, I verified it a few times.
Any hints on how to solve this would be greatly appreciated!!
Thanks!
You were right, I did but the L prefix in front of my string, and the compiler did not complain!
Now, it seems that I'm still stuck with the same problem. The output is now :
C
ÿÿÿ
0.000000
0
So it would seem that by adding the L prefix, it does not recognize my path name, and I still end up with GetShortPathName returning a 0, indicating that it does not work. I'm not sure that I made any progress...
There are problems with your fprintf() calls or even with GetShortPathName() itself as you use wchar_t explicitly. If UNICODE is defined, then first fprintf() call will fail as the third argument is wchar_t.
I think that my UNICODE is defined, but just to make sure, how do I verify it? In case it makes any difference, I am using VS2008.
If the initialization as w_char is causing the issue, what should be the type of variable that I should use in order for it to work? I am still fairly new to C++, and those string/char types are really messing me up :(