我调用这个函数来获取 exe 的路径。 GetModuleFileName(NULL, ... 问题是有时它会返回短路径 (8.3) 而不是正常的长路径。
MSDN指定
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 "\\?\".
如何避免这种行为并强制 Api 返回完整路径?
最佳答案
你无法避免它 - 如果 dll 加载了一个短名称,那就是你得到的。
使用GetLongPathName在需要时进行转换。
关于c++ - GetModuleFileName 以 8.3 格式返回路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5415996/