def WaitForSingleObject(handle, milliseconds): res = _WaitForSingleObject(int(handle), milliseconds) if res < 0: raise _WinError() return res
def CreateProcess(name, command_line, process_attr, thread_attr, inherit, flags, env, start_dir, startup_info): si = _STARTUPINFO() if startup_info is not None: si.dwFlags = startup_info.dwFlags si.wShowWindow = startup_info.wShowWindow if startup_info.hStdInput: si.hStdInput = int(startup_info.hStdInput) if startup_info.hStdOutput: si.hStdOutput = int(startup_info.hStdOutput) if startup_info.hStdError: si.hStdError = int(startup_info.hStdError) pi = _PROCESS_INFORMATION() if env is not None: envbuf = "" for k, v in env.iteritems(): envbuf += "%s=%s\0" % (k, v) envbuf += '\0' else: envbuf = None res = _CreateProcess(name, command_line, None, None, inherit, flags, envbuf, start_dir, _byref(si), _byref(pi)) if not res: raise _WinError() return _handle(pi.hProcess), _handle( pi.hThread), pi.dwProcessID, pi.dwThreadID
def CreateProcess(name, command_line, process_attr, thread_attr, inherit, flags, env, start_dir, startup_info): si = _STARTUPINFO() if startup_info is not None: si.dwFlags = startup_info.dwFlags si.wShowWindow = startup_info.wShowWindow if startup_info.hStdInput: si.hStdInput = int(startup_info.hStdInput) if startup_info.hStdOutput: si.hStdOutput = int(startup_info.hStdOutput) if startup_info.hStdError: si.hStdError = int(startup_info.hStdError) pi = _PROCESS_INFORMATION() flags |= CREATE_UNICODE_ENVIRONMENT if env is not None: envbuf = "" for k, v in env.items(): envbuf += "%s=%s\0" % (k, v) envbuf += '\0' else: envbuf = None res = _CreateProcess(name, command_line, None, None, inherit, flags, envbuf, start_dir, _byref(si), _byref(pi)) if not res: raise _WinError() return _handle(pi.hProcess), _handle(pi.hThread), pi.dwProcessID, pi.dwThreadID
def GetExitCodeProcess(handle): code = _c_int() res = _GetExitCodeProcess(int(handle), _byref(code)) if not res: raise _WinError() return code.value
def CreatePipe(attributes, size): read = _c_int() write = _c_int() res = _CreatePipe(_byref(read), _byref(write), None, size) if not res: raise _WinError() return _handle(read.value), _handle(write.value)
def DuplicateHandle(source_process, source, target_process, access, inherit, options=0): target = _c_int() res = _DuplicateHandle(int(source_process), int(source), int(target_process), _byref(target), access, inherit, options) if not res: raise _WinError() return _handle(target.value)
def TerminateProcess(handle, exitcode): res = _TerminateProcess(int(handle), exitcode) if not res: raise _WinError()