C++实现获取当前执行文件全路径
时间:2010-11-02 来源:Pegasus923
#include <Windows.h> #include <iostream> #include <string> using namespace std; string GetProgramDir() { char exeFullPath[MAX_PATH]; // Full path string strPath; GetModuleFileName(NULL,exeFullPath,MAX_PATH); strPath=(string)exeFullPath; int pos = strPath.find_last_of('\\', strPath.length()); return strPath.substr(0, pos); } int main () { string str = ""; str = GetProgramDir(); cout << str << endl; return 0; }
相关阅读 更多 +