1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
std::string find_executable( const std::string& argv0 )
{
WCHAR widename[ MAX_PATH ];
char ansiname[ MAX_PATH + MAX_PATH ];
if (GetModuleFileNameW( NULL, widename, MAX_PATH ) == 0)
{
GetModuleFileNameA( NULL, ansiname, sizeof( ansiname ) );
MultiByteToWideChar( CP_ACP, 0, ansiname, -1, widename, MAX_PATH );
}
WideCharToMultiByte( CP_UTF8, 0, widename, -1, ansiname, sizeof( ansiname ), NULL, NULL );
std::string name = ansiname;
std::replace( name.begin(), name.end(), '\\', '/' );
return name;
}
|