// Assuming unicode #include <string> wchar_t path[FILENAME_MAX] = { 0 }; GetModuleFileNameW(nullptr, path, FILENAME_MAX); std::wstring wide_string(path); std::string result_string(wide_string.begin(), wide_string.end());