Reputation: 5675
I call this function to get path to exe. GetModuleFileName(NULL, ... The problem is that sometimes it returns the short path (8.3) instead of a normal long path.
MSDN specifies that
The string returned will use the same format that was specified when the module was loaded. Therefore, the path can be a long or short file name, and can use the prefix "\\?\".
How can I avoid this behavior and force Api to return full path ?
Upvotes: 3
Views: 2465
Reputation: 91270
You cannot avoid it - if the dll is loaded with a short name, that's what you get.
Use GetLongPathName to convert if needed.
Upvotes: 4
Reputation: 72479
You cannot. Use GetFullPathName to get the full path.
See also the Remarks section in the page you linked to:
The global variable _pgmptr is automatically initialized to the full path of the executable file, and can be used to retrieve the full path name of an executable file.
Upvotes: 1