GetModuleFileName API函数未获取完整路径名 [英] GetModuleFileName API function not getting the full path name
问题描述
大家好,
请查看此代码并说明为何没有获得完整路径名。
路径是这样的:
D:\ MYYFolder \SVN_MY~1 \DEVELO~1 \SOCF9E~1 \\\\\\\\\\\\\\\\\\\\\\\\\\\\
而不是
D:\ MYYFolder \SVN_MYApp \Development\SourceCode_Ported - Win7\Release\sample_Capture.txt
Hi All,
Please check this code and suggest why it is not getting the full path name.
Path is getting like this:
D:\MYFolder\SVN_MY~1\DEVELO~1\SOCF9E~1\Release\sample_Capture.txt
instead of
D:\MYFolder\SVN_MYApp\Development\SourceCode_Ported - Win7\Release\sample_Capture.txt
CString GetExePath()const
{
TCHAR directory [200] = {ZERO_VAL};
GetModuleFileName(NULL, directory, sizeof(directory));
CString l_strFilePath = directory;
TCHAR ch = _T('\\');
int location = l_strFilePath.ReverseFind(ch) ;
l_strFilePath = l_strFilePath.Left(location+1);
return l_strFilePath;
}
谢谢
Sam
Thanks
Sam
推荐答案
GetModulePathName [ ^ ]文档提及
The GetModulePathName[^] documentation mentions
The string returned will use the same format that was specified when the module was loaded.
你是什么得到的是短路径名称 [ ^ ]
使用 GetLongPathName [ ^ ]将返回的路径转换为它的路径很长。
What you''re getting is the short path name[^]
Use GetLongPathName[^] to convert the returned path into it''s long path form.
使用
GetLongPathName
这篇关于GetModuleFileName API函数未获取完整路径名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!