diff --git a/Foundation/src/Process_WIN32.cpp b/Foundation/src/Process_WIN32.cpp index b944ce2a1..e1989c333 100644 --- a/Foundation/src/Process_WIN32.cpp +++ b/Foundation/src/Process_WIN32.cpp @@ -260,23 +260,19 @@ bool ProcessImpl::isRunningImpl(const ProcessHandleImpl& handle) { bool result = true; DWORD exitCode; - - GetExitCodeProcess(handle.process(), &exitCode); - if (exitCode != STILL_ACTIVE) result = false; - + BOOL rc = GetExitCodeProcess(handle.process(), &exitCode); + if (!rc || exitCode != STILL_ACTIVE) result = false; return result; } bool ProcessImpl::isRunningImpl(PIDImpl pid) { - HANDLE hProc = OpenProcess(PROCESS_TERMINATE, FALSE, pid); + HANDLE hProc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid); bool result = true; DWORD exitCode; - - GetExitCodeProcess(hProc, &exitCode); - if (exitCode != STILL_ACTIVE) result = false; - + BOOL rc = GetExitCodeProcess(hProc, &exitCode); + if (!rc || exitCode != STILL_ACTIVE) result = false; return result; } diff --git a/Foundation/src/Process_WIN32U.cpp b/Foundation/src/Process_WIN32U.cpp index 505a166be..226ffabe2 100644 --- a/Foundation/src/Process_WIN32U.cpp +++ b/Foundation/src/Process_WIN32U.cpp @@ -266,23 +266,19 @@ bool ProcessImpl::isRunningImpl(const ProcessHandleImpl& handle) { bool result = true; DWORD exitCode; - - GetExitCodeProcess(handle.process(), &exitCode); - if (exitCode != STILL_ACTIVE) result = false; - + BOOL rc = GetExitCodeProcess(handle.process(), &exitCode); + if (!rc || exitCode != STILL_ACTIVE) result = false; return result; } bool ProcessImpl::isRunningImpl(PIDImpl pid) { - HANDLE hProc = OpenProcess(PROCESS_TERMINATE, FALSE, pid); + HANDLE hProc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid); bool result = true; DWORD exitCode; - - GetExitCodeProcess(hProc, &exitCode); - if (exitCode != STILL_ACTIVE) result = false; - + BOOL rc = GetExitCodeProcess(hProc, &exitCode); + if (!rc || exitCode != STILL_ACTIVE) result = false; return result; } diff --git a/Foundation/src/Process_WINCE.cpp b/Foundation/src/Process_WINCE.cpp index 127a475a2..0514ef373 100644 --- a/Foundation/src/Process_WINCE.cpp +++ b/Foundation/src/Process_WINCE.cpp @@ -191,25 +191,20 @@ bool ProcessImpl::isRunningImpl(const ProcessHandleImpl& handle) { bool result = true; DWORD exitCode; - - GetExitCodeProcess(handle.process(), &exitCode); - if (exitCode != STILL_ACTIVE) result = false; - + BOOL rc = GetExitCodeProcess(handle.process(), &exitCode); + if (!rc || exitCode != STILL_ACTIVE) result = false; return result; } bool ProcessImpl::isRunningImpl(PIDImpl pid) { - HANDLE hProc = OpenProcess(PROCESS_TERMINATE, FALSE, pid); + HANDLE hProc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid); bool result = true; DWORD exitCode; - - GetExitCodeProcess(hProc, &exitCode); - if (exitCode != STILL_ACTIVE) result = false; - - return result; -} + BOOL rc = GetExitCodeProcess(hProc, &exitCode); + if (!rc || exitCode != STILL_ACTIVE) result = false; + return result;} void ProcessImpl::requestTerminationImpl(PIDImpl pid)