[python-win32] How to get PID from a Proces Handle ?
mhammond at skippinet.com.au
Thu Oct 12 13:18:34 CEST 2006
> I have some code that spawns processes using the "spawnv"
> command this returns a process handle.
> Can I use the process handle to retrieve the actual PID of
> the process ? This is part of a test harness
> and I need to be able have the actual PID to use against some output.
Good question! It's not immediately obvious how to do this simply, but at a
pinch, maybe win32pdh or WMI could be used?
Other (more painful) option is to use CreateProcess to spawn your process.
The best Python implemented example of how to do this I know of is at
content-type=text%2Fplain - the main advantage is that you can redirect the
output any place you like.
Hope that helps.
More information about the Python-win32