I need to check if a process with a given HANDLE is still runnning, I tried to do it using the following code however it always returns at the second return false, even if the process is running.
bool isProcessRunning(HANDLE process)
{
if(process == INVALID_HANDLE_VALUE)return false;
DWORD exitCode;
if(GetExitCodeProcess(process, &exitCode) != 0)
return false;//always returns here
return GetLastError() == STILL_ACTIVE;//still running
}