Confused about Process.IsValid, IsStillValid, IsRunning

delphi package - easy access to kernel objects etc.
Post Reply
SteveO
Posts: 5
Joined: Fri Jun 24, 2005 8:59 am

Confused about Process.IsValid, IsStillValid, IsRunning

Post by SteveO »

madshi,

What is the difference between IsValid, IsStillValid and IsRunning. If I launch notepad.exe the line Process('notepad.exe').IsStillValid, IsValid and IsStillRunning all return TRUE. Is there a situation where one is better to use than another?

Thanks,
SteveO
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

"IsValid" indicates whether the process was valid at the time when the interface got created. IsStillValid and IsStillRunning both return whether the process is still running. However, those two methods work slightly differently internally. IsStillValid enumerates all processes to see whether your process is still in the list of running processes. IsStillRunning uses WaitForSingleObject to see whether the process handle still indicates that your process is still running. But honestly there's no difference in practise. I'd say use IsStillRunning, cause that might be faster.
Post Reply