python类CoUninitialize()的实例源码

testGIT.py 文件源码 项目:OSPTF 作者: xSploited 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def DoTestInterpInThread(cookie):
        try:
            pythoncom.CoInitialize()
            myThread = win32api.GetCurrentThreadId()
            GIT = CreateGIT()

            interp = GIT.GetInterfaceFromGlobal(cookie, pythoncom.IID_IDispatch)
            interp = win32com.client.Dispatch(interp)

            TestInterp(interp)
            interp.Exec("import win32api")
            print "The test thread id is %d, Python.Interpreter's thread ID is %d" % (myThread, interp.Eval("win32api.GetCurrentThreadId()"))
            interp = None
            pythoncom.CoUninitialize()
        except:
            traceback.print_exc()
testGIT.py 文件源码 项目:pupy 作者: ru-faraon 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def DoTestInterpInThread(cookie):
        try:
            pythoncom.CoInitialize()
            myThread = win32api.GetCurrentThreadId()
            GIT = CreateGIT()

            interp = GIT.GetInterfaceFromGlobal(cookie, pythoncom.IID_IDispatch)
            interp = win32com.client.Dispatch(interp)

            TestInterp(interp)
            interp.Exec("import win32api")
            print "The test thread id is %d, Python.Interpreter's thread ID is %d" % (myThread, interp.Eval("win32api.GetCurrentThreadId()"))
            interp = None
            pythoncom.CoUninitialize()
        except:
            traceback.print_exc()
testGIT.py 文件源码 项目:remoteControlPPT 作者: htwenning 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def DoTestInterpInThread(cookie):
        try:
            pythoncom.CoInitialize()
            myThread = win32api.GetCurrentThreadId()
            GIT = CreateGIT()

            interp = GIT.GetInterfaceFromGlobal(cookie, pythoncom.IID_IDispatch)
            interp = win32com.client.Dispatch(interp)

            TestInterp(interp)
            interp.Exec("import win32api")
            print "The test thread id is %d, Python.Interpreter's thread ID is %d" % (myThread, interp.Eval("win32api.GetCurrentThreadId()"))
            interp = None
            pythoncom.CoUninitialize()
        except:
            traceback.print_exc()
testGIT.py 文件源码 项目:CodeReader 作者: jasonrbr 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def DoTestInterpInThread(cookie):
        try:
            pythoncom.CoInitialize()
            myThread = win32api.GetCurrentThreadId()
            GIT = CreateGIT()

            interp = GIT.GetInterfaceFromGlobal(cookie, pythoncom.IID_IDispatch)
            interp = win32com.client.Dispatch(interp)

            TestInterp(interp)
            interp.Exec("import win32api")
            print("The test thread id is %d, Python.Interpreter's thread ID is %d" % (myThread, interp.Eval("win32api.GetCurrentThreadId()")))
            interp = None
            pythoncom.CoUninitialize()
        except:
            traceback.print_exc()
polling.py 文件源码 项目:grid-control 作者: akej74 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def stop(self):
        """Stop the running thread gracefully."""

        print("Stopping thread...")
        self.keep_running = False

        # Wait for the thread to stop
        self.wait()
        print("Thread stopped")

        # Uninitialize at thread stop (used for WMI in thread)
        pythoncom.CoUninitialize()
localserver.py 文件源码 项目:OSPTF 作者: xSploited 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def serve(clsids):
    infos = factory.RegisterClassFactories(clsids)

    pythoncom.EnableQuitMessage(win32api.GetCurrentThreadId())  
    pythoncom.CoResumeClassObjects()

    pythoncom.PumpMessages()

    factory.RevokeClassFactories( infos )

    pythoncom.CoUninitialize()
testMarshal.py 文件源码 项目:OSPTF 作者: xSploited 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def _doTestInThread(self, interp):
        pythoncom.CoInitialize()
        myThread = win32api.GetCurrentThreadId()

        if freeThreaded:
            interp = pythoncom.CoGetInterfaceAndReleaseStream(interp, pythoncom.IID_IDispatch)
            interp = win32com.client.Dispatch(interp)

        interp.Exec("import win32api")
        #print "The test thread id is %d, Python.Interpreter's thread ID is %d" % (myThread, interp.Eval("win32api.GetCurrentThreadId()"))
        pythoncom.CoUninitialize()
polling.py 文件源码 项目:OpenHWControl 作者: kusti8 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def stop(self):
        """Stop the running thread gracefully."""

        print("Stopping thread...")
        self.keep_running = False

        # Wait for the thread to stop
        self.wait()
        print("Thread stopped")

        # Uninitialize at thread stop (used for WMI in thread)
        if os.name == 'nt':
            import pythoncom
            pythoncom.CoUninitialize()
localserver.py 文件源码 项目:pupy 作者: ru-faraon 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def serve(clsids):
    infos = factory.RegisterClassFactories(clsids)

    pythoncom.EnableQuitMessage(win32api.GetCurrentThreadId())  
    pythoncom.CoResumeClassObjects()

    pythoncom.PumpMessages()

    factory.RevokeClassFactories( infos )

    pythoncom.CoUninitialize()
testMarshal.py 文件源码 项目:pupy 作者: ru-faraon 项目源码 文件源码 阅读 14 收藏 0 点赞 0 评论 0
def _doTestInThread(self, interp):
        pythoncom.CoInitialize()
        myThread = win32api.GetCurrentThreadId()

        if freeThreaded:
            interp = pythoncom.CoGetInterfaceAndReleaseStream(interp, pythoncom.IID_IDispatch)
            interp = win32com.client.Dispatch(interp)

        interp.Exec("import win32api")
        #print "The test thread id is %d, Python.Interpreter's thread ID is %d" % (myThread, interp.Eval("win32api.GetCurrentThreadId()"))
        pythoncom.CoUninitialize()
__init__.py 文件源码 项目:My-Web-Server-Framework-With-Python2.7 作者: syjsu 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def deinitPerThread(self):
        import pythoncom
        pythoncom.CoUninitialize()
__init__.py 文件源码 项目:My-Web-Server-Framework-With-Python2.7 作者: syjsu 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def deinit(self):
        import pythoncom
        from win32file import CloseHandle

        for h in self.handles:
            if h is not None:
                CloseHandle(h)
        self.handles = None
        pythoncom.CoUninitialize()
        pass
leakTest.py 文件源码 项目:remoteControlPPT 作者: htwenning 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def testall():
  dotestall()
  pythoncom.CoUninitialize()
  print "AXScript Host worked correctly - %d/%d COM objects left alive." % (pythoncom._GetInterfaceCount(), pythoncom._GetGatewayCount())
localserver.py 文件源码 项目:remoteControlPPT 作者: htwenning 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def serve(clsids):
    infos = factory.RegisterClassFactories(clsids)

    pythoncom.EnableQuitMessage(win32api.GetCurrentThreadId())  
    pythoncom.CoResumeClassObjects()

    pythoncom.PumpMessages()

    factory.RevokeClassFactories( infos )

    pythoncom.CoUninitialize()
testMarshal.py 文件源码 项目:remoteControlPPT 作者: htwenning 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def _doTestInThread(self, interp):
        pythoncom.CoInitialize()
        myThread = win32api.GetCurrentThreadId()

        if freeThreaded:
            interp = pythoncom.CoGetInterfaceAndReleaseStream(interp, pythoncom.IID_IDispatch)
            interp = win32com.client.Dispatch(interp)

        interp.Exec("import win32api")
        #print "The test thread id is %d, Python.Interpreter's thread ID is %d" % (myThread, interp.Eval("win32api.GetCurrentThreadId()"))
        pythoncom.CoUninitialize()
leakTest.py 文件源码 项目:CodeReader 作者: jasonrbr 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def testall():
  dotestall()
  pythoncom.CoUninitialize()
  print("AXScript Host worked correctly - %d/%d COM objects left alive." % (pythoncom._GetInterfaceCount(), pythoncom._GetGatewayCount()))
localserver.py 文件源码 项目:CodeReader 作者: jasonrbr 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def serve(clsids):
    infos = factory.RegisterClassFactories(clsids)

    pythoncom.EnableQuitMessage(win32api.GetCurrentThreadId())  
    pythoncom.CoResumeClassObjects()

    pythoncom.PumpMessages()

    factory.RevokeClassFactories( infos )

    pythoncom.CoUninitialize()
testMarshal.py 文件源码 项目:CodeReader 作者: jasonrbr 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def _doTestInThread(self, interp):
        pythoncom.CoInitialize()
        myThread = win32api.GetCurrentThreadId()

        if freeThreaded:
            interp = pythoncom.CoGetInterfaceAndReleaseStream(interp, pythoncom.IID_IDispatch)
            interp = win32com.client.Dispatch(interp)

        interp.Exec("import win32api")
        #print "The test thread id is %d, Python.Interpreter's thread ID is %d" % (myThread, interp.Eval("win32api.GetCurrentThreadId()"))
        pythoncom.CoUninitialize()
classes.py 文件源码 项目:VBad 作者: Pepitoh 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def Quit(self):
        self.excel.Quit()
        pythoncom.CoUninitialize()
classes.py 文件源码 项目:VBad 作者: Pepitoh 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def Quit(self):
        self.word.Quit()
        #self.word.Quit()
        #os.system("taskkill /im WINWORD.exe")
        pythoncom.CoUninitialize()
__init__.py 文件源码 项目:w4py 作者: Cito 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def InstallInWebKit(appServer):
    # This function gets called by the app server during initialization.
    if not appServer.setting('EnableCOM', False):
        return  # enabling COM was not requested

    # This must be done BEFORE pythoncom is imported -- see the book mentioned above.
    import sys
    sys.coinit_flags = 0

    # Get the win32 extensions
    import pythoncom

    # Set references to the COM initialize and uninitialize functions
    appServer._initCOM = pythoncom.COINIT_MULTITHREADED
    appServer.initCOM = pythoncom.CoInitializeEx
    appServer.closeCOM = pythoncom.CoUninitialize

    # Monkey-patch this instance of the appServer

    # Grab references to the original initThread and delThread bound
    # methods, which we will replace
    appServer.originalInitThread = appServer.initThread
    appServer.originalDelThread = appServer.delThread

    # Create new versions of initThread and delThread which will call the
    # old versions

    def newInitThread(self):
        # This must be called at the beginning of any thread that uses COM
        self.initCOM(self._initCOM)
        # Call the original initThread
        self.originalInitThread()

    def newDelThread(self):
        # Call the original delThread
        self.originalDelThread()
        # Uninitialize COM
        self.closeCOM()

    # Replace the initThread and delThread methods with our new versions
    import new
    appServer.initThread = new.instancemethod(newInitThread, appServer, appServer.__class__)
    appServer.delThread = new.instancemethod(newDelThread, appServer, appServer.__class__)

    print 'COM has been enabled.'


问题


面经


文章

微信
公众号

扫码关注公众号