Click to See Complete Forum and Search --> : Getting Process state


slcoder
September 20th, 2005, 05:24 AM
I have handle to a window.
How can I get the state of the process that created this window?

golanshahar
September 20th, 2005, 05:38 AM
first thing you need to do is to get the proccess handle/id for it

DWORD pid;
DWORD dwTheardId = ::GetWindowThreadProcessId( hWnd /*handle to the window you have*/,&pid);

HANDLE hProcess = ::OpenProcess(PROCESS_ALL_ACCESS,TRUE,pid);
// now you can do your checking on the process



now it depend what you want to check?
for checking if process still active:

DWORD dwExitCode=0;
::GetExitCodeProcess(hProcess,&dwExitCode );
if ( dwExitCode == STILL_ACTIVE )
{
// process still active.
}




Cheers

slcoder
September 20th, 2005, 06:29 AM
Thank you very much!