#include <iostream>
#include <string>
#include <windows.h>
int main(int argc,char **argv)
{
char szFilePath[MAX_PATH + 1] = { 0 };
GetModuleFileNameA(NULL, szFilePath, MAX_PATH);
(strrchr(szFilePath, '\\'))[0] = 0; // 删除文件名,只获得路径字串
std::string path = szFilePath;
std::cout << path << std::endl;
}
vs2017 C++获取exe路径
最新推荐文章于 2023-06-13 17:24:20 发布