[Python-checkins] r79181 - python/trunk/Doc/faq/windows.rst
georg.brandl
python-checkins at python.org
Sun Mar 21 10:51:16 CET 2010
Author: georg.brandl
Date: Sun Mar 21 10:51:16 2010
New Revision: 79181
Log:
Update os.kill() emulation example for Windows to use ctypes.
Modified:
python/trunk/Doc/faq/windows.rst
Modified: python/trunk/Doc/faq/windows.rst
==============================================================================
--- python/trunk/Doc/faq/windows.rst (original)
+++ python/trunk/Doc/faq/windows.rst Sun Mar 21 10:51:16 2010
@@ -441,13 +441,15 @@
How do I emulate os.kill() in Windows?
--------------------------------------
-Use win32api::
+To terminate a process, you can use ctypes::
+
+ import ctypes
def kill(pid):
"""kill function for Win32"""
- import win32api
- handle = win32api.OpenProcess(1, 0, pid)
- return (0 != win32api.TerminateProcess(handle, 0))
+ kernel32 = ctypes.windll.kernel32
+ handle = kernel32.OpenProcess(1, 0, pid)
+ return (0 != kernel32.TerminateProcess(handle, 0))
Why does os.path.isdir() fail on NT shared directories?
More information about the Python-checkins
mailing list