当前位置: 首页>>代码示例>>Python>>正文


Python win32process.TerminateProcess方法代码示例

本文整理汇总了Python中win32process.TerminateProcess方法的典型用法代码示例。如果您正苦于以下问题:Python win32process.TerminateProcess方法的具体用法?Python win32process.TerminateProcess怎么用?Python win32process.TerminateProcess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在win32process的用法示例。


在下文中一共展示了win32process.TerminateProcess方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: closeApp

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import TerminateProcess [as 别名]
def closeApp(self, hProcess, title):
            """
            Close Application by window title
            """

            try:
                win32gui.EnumWindows(FileWriterLauncherGui.enumCallback, title)

                if proc is not None:
                    win32event.WaitForSingleObject(hProcess, 5 * 1000)
                    win32api.CloseHandle(hProcess)

                    for pid in self.genChildProcesses(proc):
                        try:
                            handle = win32api.OpenProcess(1, False, pid)
                            win32process.TerminateProcess(handle, -1)
                            win32api.CloseHandle(handle)
                        except:
                            pass

            except:
                pass 
开发者ID:MozillaSecurity,项目名称:peach,代码行数:24,代码来源:process.py

示例2: kill

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import TerminateProcess [as 别名]
def kill(self, gracePeriod=5000):
        """
        Kill process. Try for an orderly shutdown via WM_CLOSE.  If
        still running after gracePeriod (5 sec. default), terminate.
        """
        win32gui.EnumWindows(self.__close__, 0)
        if self.wait(gracePeriod) != win32event.WAIT_OBJECT_0:
            win32process.TerminateProcess(self.hProcess, 0)
            win32api.Sleep(100) # wait for resources to be released 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:winprocess.py

示例3: signalProcess

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import TerminateProcess [as 别名]
def signalProcess(self, signalID):
        if self.pid is None:
            raise error.ProcessExitedAlready()
        if signalID in ("INT", "TERM", "KILL"):
            win32process.TerminateProcess(self.hProcess, 1) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:7,代码来源:_dumbwin32proc.py

示例4: terminate

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import TerminateProcess [as 别名]
def terminate(self):
            win32process.TerminateProcess(self._handle, 1) 
开发者ID:refack,项目名称:GYP3,代码行数:4,代码来源:TestCmd.py

示例5: kill

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import TerminateProcess [as 别名]
def kill(self):
        handle = win32api.OpenProcess(
            win32con.PROCESS_VM_READ | win32con.PROCESS_TERMINATE, pywintypes.FALSE, self.childpid)
        win32process.TerminateProcess(handle, 3) 
开发者ID:kdart,项目名称:pycopia,代码行数:6,代码来源:WindowsServer.py

示例6: enumCallback

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import TerminateProcess [as 别名]
def enumCallback(hwnd, windowName):
            """
            Will get called by win32gui.EnumWindows, once for each
            top level application window.
            """

            try:

                # Get window title
                title = win32gui.GetWindowText(hwnd)

                # Is this our guy?
                if title.find(windowName) == -1:
                    return

                (threadId, processId) = win32process.GetWindowThreadProcessId(hwnd)

                # Send WM_CLOSE message
                try:
                    win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
                    win32gui.PostQuitMessage(hwnd)
                except:
                    pass

                # Give it upto 5 sec
                for i in range(100):
                    if win32process.GetExitCodeProcess(processId) != win32con.STILL_ACTIVE:
                        # Process exited already
                        return

                    time.sleep(0.25)

                try:
                    # Kill application
                    win32process.TerminateProcess(processId, 0)
                except:
                    pass
            except:
                pass 
开发者ID:MozillaSecurity,项目名称:peach,代码行数:41,代码来源:tcp.py

示例7: signalProcess

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import TerminateProcess [as 别名]
def signalProcess(self, signalID):
        if signalID in ("INT", "TERM", "KILL"):
            win32process.TerminateProcess(self.hProcess, 1) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:5,代码来源:_dumbwin32proc.py

示例8: callWindows

# 需要导入模块: import win32process [as 别名]
# 或者: from win32process import TerminateProcess [as 别名]
def callWindows(self):
        """
        Launch program to consume file
        """

        # Launch via spawn

        realArgs = ["cmd.exe", "/c", self.command]
        for a in self.args:
            realArgs.append(a)

        phandle = os.spawnv(os.P_NOWAIT, os.path.join(os.getenv('SystemRoot'), 'system32', 'cmd.exe'), realArgs)

        # Give it some time before we KILL!
        for i in range(int(self.waitTime / 0.25)):
            if win32process.GetExitCodeProcess(phandle) != win32con.STILL_ACTIVE:
                # Process exited already
                break

            time.sleep(0.25)

        try:
            pid = ctypes.windll.kernel32.GetProcessId(ctypes.c_ulong(phandle))
            if pid > 0:
                for cid in self.FindChildrenOf(pid):

                    chandle = win32api.OpenProcess(1, 0, cid)
                    win32process.TerminateProcess(chandle, 0)

                    try:
                        win32api.CloseHandle(chandle)
                    except:
                        pass

            win32process.TerminateProcess(phandle, 0)

            try:
                win32api.CloseHandle(phandle)
            except:
                pass

        except:
            pass 
开发者ID:MozillaSecurity,项目名称:peach,代码行数:45,代码来源:process.py


注:本文中的win32process.TerminateProcess方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。