本文整理匯總了Python中win32process.STARTF_USESTDHANDLES屬性的典型用法代碼示例。如果您正苦於以下問題:Python win32process.STARTF_USESTDHANDLES屬性的具體用法?Python win32process.STARTF_USESTDHANDLES怎麽用?Python win32process.STARTF_USESTDHANDLES使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類win32process
的用法示例。
在下文中一共展示了win32process.STARTF_USESTDHANDLES屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: start
# 需要導入模塊: import win32process [as 別名]
# 或者: from win32process import STARTF_USESTDHANDLES [as 別名]
def start(self, cmd):
sAttr = win32security.SECURITY_ATTRIBUTES()
sAttr.bInheritHandle = True
stdout_r, stdout_w = win32pipe.CreatePipe(sAttr,0)
stdin_r, stdin_w = win32pipe.CreatePipe(sAttr,0)
self.read_handle=stdout_r
self.write_handle=stdout_w
self.stdin_write=stdin_w
si = win32process.STARTUPINFO()
si.dwFlags = win32process.STARTF_USESHOWWINDOW | win32process.STARTF_USESTDHANDLES
si.wShowWindow = win32con.SW_HIDE
si.hStdInput = stdin_r # file descriptor of origin stdin
si.hStdOutput = stdout_w
si.hStdError = stdout_w
hProcess, hThread, dwProcessID, dwThreadID = win32process.CreateProcess(None,"cmd", None, None, True, win32process.CREATE_NEW_CONSOLE, None, None, si)
self.dwProcessID=dwProcessID
self.hProcess=hProcess
sleep(0.5)
if self.hProcess == 0:
DebugOutput("Start Process Fail:{:d}".format(win32api.GetLastError()))
DebugOutput('[*] pid: {:x}'.format(self.dwProcessID))
self.Console_hwnd = get_hwnds_for_pid(self.dwProcessID)
if len(self.Console_hwnd)==0:
raise Exception("Fail to run,No Process!")
DebugOutput('[*] hwnd:{:x}'.format(self.Console_hwnd[0]))