hey so i made this real quick :
std::string ProcessIdToName(DWORD processId)
{
std::string ret;
HANDLE handle = OpenProcess(
PROCESS_QUERY_LIMITED_INFORMATION,
FALSE,
processId /* This is the PID, you can find one from windows task manager */
);
if (handle)
{
DWORD buffSize = 1024;
CHAR buffer[1024];
if (QueryFullProcessImageNameA(handle, 0, buffer, &buffSize))
{
ret = buffer;
}
else
{
printf("Error GetModuleBaseNameA : %lu", GetLastError());
}
CloseHandle(handle);
}
else
{
printf("Error OpenProcess : %lu", GetLastError());
}
return ret;
}
int main()
{
std::cout << ProcessIdToName(GetCurrentProcessId());
}
output :
C:\Users\-_-\source\repos\Project1\x64\Release\Project1.exe
i need to remove
C:\Users\-_-\source\repos\Project1\x64\Release\
and only keep the name of the exe like this
Project1.exe
thanks for the help, heres what im talking about : so i will get the full path of the current process and i just want to keep the name of the exe like i mentioned above so in short words i just want to get the name of the exe not full path.