调用了Win API
#include <iostream>
#include <string>
#include <windows.h>
using namespace std;
wstring GetRunDir()
{
wstring Path;
wchar_t szModule[1024] = { 0 };
GetModuleFileName(NULL, szModule, sizeof(szModule) / sizeof(szModule[0]));
Path = szModule;
Path.erase(Path.find_last_of(L'\\'));
return Path;
}
int main()
{
std::wcout << GetRunDir();
}