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


Python pythoncom.CoInitialize方法代码示例

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


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

示例1: connect

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoInitialize [as 别名]
def connect(connstr, timeout=30):               #v2.1 Simons
    "Connection string as in the ADO documentation, SQL timeout in seconds"
    try:
        if not onIronPython:
            pythoncom.CoInitialize()             #v2.1 Paj
        conn=Dispatch('ADODB.Connection') #connect _after_ CoIninialize v2.1.1 adamvan
    except:
        raise InterfaceError #Probably COM Error
    try:
        conn.CommandTimeout=timeout             #v2.1 Simons
        conn.ConnectionString=connstr
    except:
        raise Error
    if verbose:
        print '%s attempting: "%s"' % (version,connstr)
    try:
        conn.Open()
    except (Exception), e:
        raise DatabaseError(e) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:21,代码来源:adodbapi.py

示例2: DoTestInterpInThread

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoInitialize [as 别名]
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() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:testGIT.py

示例3: test

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoInitialize [as 别名]
def test(self, upnp_type):
        if DEBUG:
            print >> sys.stderr, 'upnpX: testing UPnP type ' + str(upnp_type)
        if not upnp_type or self.get_ip() is None or upnp_type <= 2 and not win32_imported:
            if DEBUG:
                print >> sys.stderr, 'upnpX: UPnP not supported'
            return 0
        if upnp_type != 3:
            pythoncom.CoInitialize()
        self.upnp = self.upnplist[upnp_type]
        if self.upnp.test():
            if DEBUG:
                print >> sys.stderr, 'upnpX: ok'
            return upnp_type
        if DEBUG:
            print >> sys.stderr, 'upnpX: tested bad'
        return 0 
开发者ID:alesnav,项目名称:p2ptv-pi,代码行数:19,代码来源:natpunch.py

示例4: _get_emails

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoInitialize [as 别名]
def _get_emails():
    pythoncom.CoInitialize()
    outlook = win32com.client.Dispatch('Outlook.Application').GetNameSpace('MAPI')
    inbox   = outlook.GetDefaultFolder(6)
    unread  = inbox.Items
    while True:
        email = None
        try:
            email = unread.GetNext()
        except:
            break
        if email:
            sender   = email.SenderEmailAddress.encode('ascii','ignore')
            message  = email.Body.encode('ascii','ignore')[:100] + '...'
            subject  = email.Subject.encode('ascii','ignore')
            received = str(email.ReceivedTime).replace('/','-').replace('\\','')
            globals()['results'][received] = {'from': sender, 'subject': subject, 'message': message}
        else:
            break 
开发者ID:malwaredllc,项目名称:byob,代码行数:21,代码来源:outlook.py

示例5: AddThread

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoInitialize [as 别名]
def AddThread(self, voice, rate, voiceText, suffix, volume, audio):
        pythoncom.CoInitialize()

        if suffix:
            suffix = self.text.suffix + '.' + suffix
        else:
            suffix = self.text.suffix

        tts = self.GetTTS()
        if not tts:
            return
        tts.Voice = self.GetVoice(tts, voice)
        if audio:
            tts.AudioOutput = self.GetAudio(tts, audio)
        tts.Volume = volume
        tts.Rate = rate
        tts_id = pythoncom.CoMarshalInterThreadInterfaceInStream(
            pythoncom.IID_IDispatch,
            tts
        )

        t = Speaker(self, tts_id, voiceText, suffix)
        t.start()
        self.threads.append(t) 
开发者ID:EventGhost,项目名称:EventGhost,代码行数:26,代码来源:__init__.py

示例6: _query_sample_loop

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoInitialize [as 别名]
def _query_sample_loop(self):
        try:
            # Initialize COM for the current (dedicated) thread
            # WARNING: any python COM object (locator, connection, etc) created in a thread
            # shouldn't be used in other threads (can lead to memory/handle leaks if done
            # without a deep knowledge of COM's threading model).
            pythoncom.CoInitialize()
        except Exception as e:
            self.logger.info("exception in CoInitialize: %s", e)
            raise

        while True:
            self._runSampleEvent.wait()
            if self._stopping:
                self.logger.debug("_query_sample_loop stopping")
                self._sampleCompleteEvent.set()
                return

            self._runSampleEvent.clear()
            if self.is_raw_perf_class and not self._previous_sample:
                self._current_sample = self._query()

            self._previous_sample = self._current_sample
            self._current_sample = self._query()
            self._sampleCompleteEvent.set() 
开发者ID:DataDog,项目名称:integrations-core,代码行数:27,代码来源:sampler.py

示例7: get_reader

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoInitialize [as 别名]
def get_reader(cls):
        import wmi
        import pythoncom

        def temperature_reader():
            pythoncom.CoInitialize()
            w = wmi.WMI(namespace='root\\wmi')
            temperature = w.MSAcpi_ThermalZoneTemperature()[0]
            temperature = int(temperature.CurrentTemperature / 10.0 - 273.15)
            return temperature
        return temperature_reader 
开发者ID:it-geeks-club,项目名称:pyspectator,代码行数:13,代码来源:temperature_reader.py

示例8: _detectRunningProcesses

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoInitialize [as 别名]
def _detectRunningProcesses(self):
        pythoncom.CoInitialize()
        procs = []
        w = wmi.WMI ()
        for process in w.Win32_Process ():
            procs.append('{0};{1}'.format(process.ProcessId, process.Name))
        return procs 
开发者ID:maldevel,项目名称:gdog,代码行数:9,代码来源:client.py

示例9: _detectServices

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoInitialize [as 别名]
def _detectServices(self):
        pythoncom.CoInitialize()
        srvs = []
        w = wmi.WMI ()
        for service in w.Win32_Service ():
            srvs.append('{0};{1}'.format(service.Name, str(service.StartMode)))
        return srvs 
开发者ID:maldevel,项目名称:gdog,代码行数:9,代码来源:client.py

示例10: get_hardware_info

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoInitialize [as 别名]
def get_hardware_info(response):
    pythoncom.CoInitialize()
    win32 = wmi.WMI()

    hardware = response["hardware"]

    hardware.append({Klanguage().to_ts(1011) : [get_cpu_info()]})
    #hardware.append({'Memory' : [""]})
    hardware.append({Klanguage().to_ts(1016) : get_disk_partition(win32)})
    hardware.append({Klanguage().to_ts(1017) : [get_bios_info()]})
    hardware.append({Klanguage().to_ts(1013) : get_gpu_info(win32)})
    hardware.append({Klanguage().to_ts(1012) : get_network_card_info()})

    pythoncom.CoUninitialize() 
开发者ID:turingsec,项目名称:marsnake,代码行数:16,代码来源:overview_win.py

示例11: initialize

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoInitialize [as 别名]
def initialize():
    logging.root.setLevel(logging.DEBUG)
    fmt = '%(asctime)s.%(msecs)03d %(name)s %(levelname)s %(message)s'
    datefmt = '%H:%M:%S'
    the_handler = logging.handlers.RotatingFileHandler(
        osdriver.mbusb_log_file(), 'a', 1024*1024, 5)
    the_handler.setFormatter(logging.Formatter(fmt, datefmt))
    logging.root.addHandler(the_handler)

    if platform.system() == 'Windows':
        import pythoncom
        pythoncom.CoInitialize() 
开发者ID:mbusb,项目名称:multibootusb,代码行数:14,代码来源:osdriver.py

示例12: collect

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoInitialize [as 别名]
def collect(self):
        # Needs to be called if using com from a thread.
        pythoncom.CoInitialize()

        wmi_obj = win32com.client.GetObject(self.plugin_args.baseobj)

        # This allows our WMI to do some extra things, in particular
        # it gives it access to find the executable path for all processes.
        wmi_obj.Security_.Privileges.AddAsString("SeDebugPrivilege")

        # Run query
        try:
            query_results = wmi_obj.ExecQuery(self.plugin_args.query)
        except pythoncom.com_error as e:
            raise plugin.PluginError(
                "Failed to run WMI query \'%s\' err was %s" % (
                    self.plugin_args.query, e))

        # Extract results from the returned COMObject and return dicts.
        try:
            for result in query_results:
                yield dict(Result=WmiResult(result))

        except pythoncom.com_error as e:
            raise plugin.PluginError(
                "WMI query data error on query \'%s\' err was %s" %
                (e, self.plugin_args.query)) 
开发者ID:google,项目名称:rekall,代码行数:29,代码来源:windows.py

示例13: _doTestInThread

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoInitialize [as 别名]
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() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:testMarshal.py

示例14: _detectUsers

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoInitialize [as 别名]
def _detectUsers(self):
        pythoncom.CoInitialize()
        usr = []
        w = wmi.WMI ()
        for user in w.Win32_UserAccount ():
            usr.append('{0};{1};{2}'.format(user.Name, str(AccountType(user.AccountType)).split('.')[1], 'Disabled' if user.Disabled else 'Enabled'))
        return usr 
开发者ID:maldevel,项目名称:gdog,代码行数:9,代码来源:client.py

示例15: _detectDevices

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoInitialize [as 别名]
def _detectDevices(self):
        pythoncom.CoInitialize()
        devs = []
        w = wmi.WMI ()
        for dev in w.Win32_PnPEntity ():
            devs.append('{0};{1}'.format(dev.Name, dev.Manufacturer))
        return devs 
开发者ID:maldevel,项目名称:gdog,代码行数:9,代码来源:client.py


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