本文整理匯總了Python中win32security.SECURITY_ATTRIBUTES屬性的典型用法代碼示例。如果您正苦於以下問題:Python win32security.SECURITY_ATTRIBUTES屬性的具體用法?Python win32security.SECURITY_ATTRIBUTES怎麽用?Python win32security.SECURITY_ATTRIBUTES使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類win32security
的用法示例。
在下文中一共展示了win32security.SECURITY_ATTRIBUTES屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: import win32security [as 別名]
# 或者: from win32security import SECURITY_ATTRIBUTES [as 別名]
def __init__(self, filename):
self._hfile = win32file.CreateFile(filename,
win32con.GENERIC_READ | win32con.GENERIC_WRITE,
win32con.FILE_SHARE_READ | win32con.FILE_SHARE_WRITE,
win32security.SECURITY_ATTRIBUTES(),
win32con.OPEN_EXISTING,
win32con.FILE_FLAG_OVERLAPPED,
0)
self._read_ovrlpd = pywintypes.OVERLAPPED()
self._read_ovrlpd.hEvent = win32event.CreateEvent(None, True,
False, None)
self._write_ovrlpd = pywintypes.OVERLAPPED()
self._write_ovrlpd.hEvent = win32event.CreateEvent(None, True,
False, None)
self._bufs = []
self._n = 0
示例2: start
# 需要導入模塊: import win32security [as 別名]
# 或者: from win32security import SECURITY_ATTRIBUTES [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]))