News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

isprocessactive

Started by Slugsnack, July 26, 2009, 05:31:54 PM

Previous topic - Next topic

Slugsnack

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() : )

bruce1948

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.





ToutEnMasm

CreateToolhelp32Snapshot is the one to do all you want
when you have the processid
invoke OpenProcess,PROCESS_ALL_ACCESS,FALSE, ProcessID

Tedd

WaitForSingleObject with the process handle - I already told you this one :bdg
No snowflake in an avalanche feels responsible.

Slugsnack

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 !