The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Slugsnack on July 26, 2009, 05:31:54 PM

Title: isprocessactive
Post by: Slugsnack on July 26, 2009, 05:31:54 PM
is there such a function ? looked everywhere, doesn't seem to be. is there a better way of telling whether a process is still active other than enumprocesses ? i have the handle to a process and want a way to poll to see whether it is still active basically. enumprocesses seems like overkill.. so i'm basically looking for the process equivalent of iswindow() : )
Title: Re: isprocessactive
Post by: bruce1948 on July 26, 2009, 06:13:42 PM
Hi,

Try a loop using GetExitCodeProcess

The GetExitCodeProcess function retrieves the termination status of the specified process.

BOOL GetExitCodeProcess(

    HANDLE hProcess,   // handle to the process
    LPDWORD lpExitCode    // address to receive termination status
   );   

The handle must have PROCESS_QUERY_INFORMATION access.
If the specified process has not terminated, the termination status returned is STILL_ACTIVE.




Title: Re: isprocessactive
Post by: ToutEnMasm on July 26, 2009, 06:23:11 PM
CreateToolhelp32Snapshot is the one to do all you want
when you have the processid
invoke OpenProcess,PROCESS_ALL_ACCESS,FALSE, ProcessID
Title: Re: isprocessactive
Post by: Tedd on July 26, 2009, 09:16:43 PM
WaitForSingleObject with the process handle - I already told you this one :bdg
Title: Re: isprocessactive
Post by: Slugsnack on July 27, 2009, 01:11:03 PM
bruce1948 : that solution seems to be good.. will check that out later
ToutEnMasm : yes that is similar to the EnumProcesses method but with more work. the reason i want to avoid using either of those is that it seems to be.. wasteful
Tedd : yeah that is the method i am currently using. it's good for some parts of my program but i am wanting to check a lot of processes quite quickly. well a lot being like.. 4 haha. i guess i could use that function with a small wait time then check for the return though. however GetExitCodeProcess seems to suit my criteria for the time being ^_^

thanks all !