[python-win32] Any way to get PyHANDLE for any running process?

Mark Hammond mhammond at skippinet.com.au
Fri Jul 2 19:35:33 EDT 2004


> I am having a problem of a process not closing when it
> should, actually
> stemming from IE's COM object, and it prevents me from
> creating another
> IE COM object.  I would like to have some way to check if
> IEXPLORE.EXE
> is already running, and if so, then kill it.
>
> I noticed win32process.TerminateProcess(), but it wants a
> PyHANDLE and I
> can't figure out how to create one for any process other than the
> currently running one.
>
> Any help on this would be great.  Already sick of doing it manually
> through the Task Manager.

See the other replies - but first, you should try and fix it "cleanly".  IE
should die when the last reference to it is released, and Visible is not set
to True.  If this doesn't happen, there is a good chance you have references
to IE still hanging around your code.  Looking at the value of
pythoncom._GetInterfaceCount() should tell you this.  If you have the
problem even when _GetInterfaceCount() returns 0, then you have no choice -
but if _GetInterfaceCount() is non-zero, then try locating where these
references are, and have it report 0.  The problem may then magically vanish
(just like IE!)

Mark
>
> -Brett
>
> _______________________________________________
> Python-win32 mailing list
> Python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32




More information about the Python-win32 mailing list