1.先添加头文件 #include "Shlwapi.h" 2.CString GetExePath(void)//获取.exe文件的目录 { TCHAR lpPath[_MAX_PATH + 1] = { 0 }; ::GetModuleFileName(NULL, lpPath, _MAX_PATH);//得到应用程序的全路径 //如:c:/debug/test.exe ::PathRemoveFileSpec(lpPath);//分离路径,得到目录 //如:c:/debug/ return lpszModulePath; }