Home Ask Login Register

Developers Planet

Your answer is one click away!

user2346536 February 2016

how to wait for a non-child process with winapi?

I read:

Code snippet:

HANDLE  hProcess = OpenProcess(SYNCHRONIZE, TRUE, inProcessID); 

if (NULL == hProcess)

I've tried WaitForSingleObject and WaitForSingleObjectEx, neither are actually waiting.

For example assume notepad is running and I want to wait for it to be closed by some user. What shall I do ?


0xFFFFFFFF February 2016

From the documentation for OpenProcess:

If the function succeeds, the return value is an open handle to the specified process.

If the function fails, the return value is NULL. To get extended error information, call GetLastError.

So your if statement should be:

if (NULL != hProcess) ...

Post Status

Asked in February 2016
Viewed 1,824 times
Voted 13
Answered 1 times


Leave an answer

Quote of the day: live life