Python pythoncom 模块,CoUninitialize() 实例源码

我们从Python开源项目中,提取了以下21个代码示例,用于说明如何使用pythoncom.CoUninitialize()

项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
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()
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
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()
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
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()
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
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()
项目:grid-control    作者:akej74    | 项目源码 | 文件源码
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()
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def serve(clsids):
    infos = factory.RegisterClassFactories(clsids)

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

    pythoncom.PumpMessages()

    factory.RevokeClassFactories( infos )

    pythoncom.CoUninitialize()
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
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()
项目:OpenHWControl    作者:kusti8    | 项目源码 | 文件源码
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()
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def serve(clsids):
    infos = factory.RegisterClassFactories(clsids)

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

    pythoncom.PumpMessages()

    factory.RevokeClassFactories( infos )

    pythoncom.CoUninitialize()
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
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()
项目:My-Web-Server-Framework-With-Python2.7    作者:syjsu    | 项目源码 | 文件源码
def deinitPerThread(self):
        import pythoncom
        pythoncom.CoUninitialize()
项目:My-Web-Server-Framework-With-Python2.7    作者:syjsu    | 项目源码 | 文件源码
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
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def testall():
  dotestall()
  pythoncom.CoUninitialize()
  print "AXScript Host worked correctly - %d/%d COM objects left alive." % (pythoncom._GetInterfaceCount(), pythoncom._GetGatewayCount())
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def serve(clsids):
    infos = factory.RegisterClassFactories(clsids)

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

    pythoncom.PumpMessages()

    factory.RevokeClassFactories( infos )

    pythoncom.CoUninitialize()
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
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()
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def testall():
  dotestall()
  pythoncom.CoUninitialize()
  print("AXScript Host worked correctly - %d/%d COM objects left alive." % (pythoncom._GetInterfaceCount(), pythoncom._GetGatewayCount()))
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def serve(clsids):
    infos = factory.RegisterClassFactories(clsids)

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

    pythoncom.PumpMessages()

    factory.RevokeClassFactories( infos )

    pythoncom.CoUninitialize()
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
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()
项目:VBad    作者:Pepitoh    | 项目源码 | 文件源码
def Quit(self):
        self.excel.Quit()
        pythoncom.CoUninitialize()
项目:VBad    作者:Pepitoh    | 项目源码 | 文件源码
def Quit(self):
        self.word.Quit()
        #self.word.Quit()
        #os.system("taskkill /im WINWORD.exe")
        pythoncom.CoUninitialize()
项目:w4py    作者:Cito    | 项目源码 | 文件源码
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.'