I have a test manager that needs to know when the test (exe's) have
completed.
Both your suggestions work, thank you for those.
My sample code was too abbreviated (see eom). I do call CloseHandle(). Which
is why it worked on Win2k.
Now that I have a solution, I am curious as to why 2003 Server seems to
behave differently.
Thanks again
-Darren
HANDLE hProcess = OpenProcess(READ_CONTROL, FALSE, <ProcessId>);
while (hProcess) {
CloseHandle(hProcess)
hProcess = OpenProcess(READ_CONTROL, FALSE, <ProcessId>);
// Process terminates but I keep getting a non-NULL hProcess on Windows
2003 Server
}
"John Phillips" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> OpenProcess will -=not necessarily=- return NULL even if the process has
> terminated. The process object will remain valid until all handles to it
> are closed (BTW, in your sample code, this will never happen as you keep
> creating a new handle to the process on every iteration without ever
closing
> any).
>
> What are you really trying to accomplish? Are you trying to determine
> whether or not the process has exited? In that case, may I suggest either
> polling via GetExitCodeProcess() or the more elegant
> WaitForSingleObject(hProcess)?
>
>
> --
> John Phillips
> MVP - Windows SDK
>
>
>
> "Darren Kennedy" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > (Apologies if posting to wrong group. Is there a Windows 2003 Server
> > dev group?)
> >
> > When I run the OpenProcess() function on Windows 2003, I continue to
> > get a non-NULL handle on a process that has terminated.
> >
> > HANDLE hProcess = OpenProcess(READ_CONTROL, FALSE, <ProcessId>);
> > while (hProcess)
> > {
> > hProcess = OpenProcess(READ_CONTROL, FALSE, <ProcessId>);
> > // Process terminates but I keep getting a non-NULL hProcess
> > }
> >
> > Works as expected on Windows 2000 but not on Windows 2003 Server.
> >
> > Any ideas?
> >
> > Thanks
> > -Darren
>
>
|