470
470
def get_app_path(appname):
471
r"""Look up in Windows registry for full path to application executable.
471
"""Look up in Windows registry for full path to application executable.
472
472
Typically, applications create subkey with their basename
473
473
in HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\
578
578
get_unicode_argv = None
582
def _pywin32_is_local_pid_dead(pid):
583
"""True if pid doesn't correspond to live process on this machine"""
585
handle = win32api.OpenProcess(1, False, pid) # PROCESS_TERMINATE
586
except pywintypes.error, e:
587
if e[0] == 5: # ERROR_ACCESS_DENIED
588
# Probably something alive we're not allowed to kill
590
elif e[0] == 87: # ERROR_INVALID_PARAMETER
595
is_local_pid_dead = _pywin32_is_local_pid_dead
596
elif has_ctypes and sys.platform == 'win32':
597
from ctypes.wintypes import BOOL, DWORD, HANDLE
598
_kernel32 = ctypes.windll.kernel32
599
_CloseHandle = ctypes.WINFUNCTYPE(BOOL, HANDLE)(
600
("CloseHandle", _kernel32))
601
_OpenProcess = ctypes.WINFUNCTYPE(HANDLE, DWORD, BOOL, DWORD)(
602
("OpenProcess", _kernel32))
603
def _ctypes_is_local_pid_dead(pid):
604
"""True if pid doesn't correspond to live process on this machine"""
605
handle = _OpenProcess(1, False, pid) # PROCESS_TERMINATE
607
errorcode = ctypes.GetLastError()
608
if errorcode == 5: # ERROR_ACCESS_DENIED
609
# Probably something alive we're not allowed to kill
611
elif errorcode == 87: # ERROR_INVALID_PARAMETER
613
raise ctypes.WinError(errorcode)
616
is_local_pid_dead = _ctypes_is_local_pid_dead