c ++ obtain the location where the current process

char buffer[MAX_PATH];
GetModuleFileNameA(NULL, buffer, MAX_PATH );
string::size_type pos = string( buffer ).find_last_of( "\\/" );
string currentPath = string(buffer).substr( 0, pos);
CHAR fullPath[MAX_PATH];
sprintf(fullPath ,"%s\\%s" ,currentPath.c_str() ,"Demo.exe");

 

Guess you like

Origin www.cnblogs.com/nanfei/p/12071881.html