Stef Mientki wrote:
How to determine if a process (known pid) os still running ?
Googling the web, I found 1 solution in killing the process,
but that's not what I want, I want to reuse the running process.
I could also ask a complete list of active processes,
but from my experiences that's quite slow.
Any better solutions ?
I'm not entirely sure what you're trying to achieve,
or what "reuse the running process" means. This WMI
snippet will tell you whether a given pid is running
or not. As you may know, WMI isn't the fastest thing
on earth, but it may be fast enough for you.
<code>
import wmi
pid = int (raw_input ("Enter PID:"))
c = wmi.WMI (find_classes=False)
for process in c.Win32_Process ([], ProcessId=pid):
print "PID %s in use by %s" % (pid, process.Caption)
break
else:
print "PID %d not in use" % pid
</code>
TJG
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32