头文件#include <windows.h>
char moduleFileName[MAX_PATH];
GetModuleFileNameA(0, moduleFileName, MAX_PATH);
取得的路径为:c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects
\Test\debug\Test.exe
char moduleFileName[MAX_PATH];
GetModuleFileNameA(NULL, moduleFileName, MAX_PATH);
std::string workingFolder(moduleFileName);
size_t pos = workingFolder.find_last_of("\\");
workingFolder = workingFolder.substr(0, pos+1);
std::cout<<workingFolder<<std::endl;
取得的路径为:c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects
\Test\debug\
char result[MAX_PATH];
GetCurrentDirectoryA(MAX_PATH, result);
取得的路径为:c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects
\Test\Test
分享到:
相关推荐
在PB中获得当前应用程序执行时所在的目录和Exe名称。使用API函数GetModuleFileNameA。
一大堆的宏和函数搞得我头晕脑涨。所以配置文件如果有错误,也在所难免,所有修改的文件,如config.h,iconv.h,libintl.h都附带了原始文件。 如: 配置文件 原始文件 DLL原始文件 LIB原始文件 config.h config.h.in...
获取当前所有应用程序.txt
//以上就是我常用的几个日志函数了,当然还有很多更加强大的日志相关函数,大家如有有兴趣,可以参照官方给的示例使用, //开源代码地址:https://github.com/google/glog MessageBoxA(NULL,"Test Over",":)",MB_...
这个是问答区回答一个易友的,顺便发到这里。 用于HOOK修改 GetModuleFileNameW 返回的结果,同时 GetModuleFileNameA 也会被HOOK.