c++ - GetModuleFileName 以 8.3 格式返回路径

标签 c++ winapi

我调用这个函数来获取 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/

相关文章:

c++ - SSE2 内在函数在哪里存储结果?

winapi - "Image File Execution Options"是否拦截CreateProcess命令?

c++ - 如何使用 WM_NCHITTEST 从子窗口 move 无边框的父窗口

windows - 如何处理来自单独线程的窗口消息?

c++ - 参数是对文字类型的引用时的常量函数

c++ - 测量分布式应用程序的内存使用情况

android - 使用 Eclipse 在 Android NDK 项目中构建 C++ 文件时出错

c++ - 如何在 Qt 5.1.0 中将主窗口对齐到屏幕的右侧

c++ - DirectX 小应用程序像 hell 一样消耗资源

c++ - ExtTextOut 文本不断闪烁,并且在设定的时间后文本恢复为默认字体