(pid)
return code.value == STILL_ACTIVE
Process detection for win32.
Process detection for win32.
Process detection for win32 .
def win32_detect_pid(pid):
    """Process detection for win32."""

    # avoid pywin32 dependecy, use ctypes instead
    import ctypes

    # win32 constants
    PROCESS_QUERY_INFORMATION = 1024
    STILL_ACTIVE = 259
    ERROR_INVALID_PARAMETER = 87
    ERROR_ACCESS_DENIED = 5

    # Load kernel32.dll
    k = ctypes.windll.kernel32
    OpenProcess = k.OpenProcess
    OpenProcess.restype = ctypes.c_void_p

    # query pid exit code
    h = OpenProcess(PROCESS_QUERY_INFORMATION, 0, pid)
    if h == None:
        err = k.GetLastError()
        if err == ERROR_INVALID_PARAMETER:
            return False
        if err == ERROR_ACCESS_DENIED:
            return True
        raise OSError(errno.EFAULT, "Unknown win32error: " + str(err))
    code = ctypes.c_int()
    k.GetExitCodeProcess(h, ctypes.byref(code))
    k.CloseHandle(h)
    return code.value == STILL_ACTIVE
def win32_detect_pid ( pid ) : # avoid pywin32 dependecy, use ctypes instead import ctypes # win32 constants PROCESS_QUERY_INFORMATION = 1024 STILL_ACTIVE = 259 ERROR_INVALID_PARAMETER = 87 ERROR_ACCESS_DENIED = 5 # Load kernel32.dll k = ctypes . windll . kernel32 OpenProcess = k . OpenProcess OpenProcess . restype = ctypes . c_void_p # query pid exit code h = OpenProcess ( PROCESS_QUERY_INFORMATION , 0 , pid ) if h == None : err = k . GetLastError ( ) if err == ERROR_INVALID_PARAMETER : return False if err == ERROR_ACCESS_DENIED : return True raise OSError ( errno . EFAULT , "Unknown win32error: " + str ( err ) ) code = ctypes . c_int ( ) k . GetExitCodeProcess ( h , ctypes . byref ( code ) ) k . CloseHandle ( h ) return code . value == STILL_ACTIVE