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


Python pythoncom.CoCreateInstance方法代码示例

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


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

示例1: __init__

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoCreateInstance [as 别名]
def __init__(self, interfaceMaker = None, processName = None):
        if processName is None: processName = "Python Process"
        if interfaceMaker is None: interfaceMaker = SimpleHostStyleInterfaceMaker()

        self.pydebugger = adb.Debugger()

        self.pdm=pythoncom.CoCreateInstance(axdebug.CLSID_ProcessDebugManager,None,pythoncom.CLSCTX_ALL, axdebug.IID_IProcessDebugManager)

        self.app, self.root = interfaceMaker.MakeInterfaces(self.pdm)
        self.app.SetName(processName)
        self.interfaceMaker = interfaceMaker

        expressionProvider = _wrap(expressions.ProvideExpressionContexts(), axdebug.IID_IProvideExpressionContexts)
        self.expressionCookie = self.app.AddGlobalExpressionContextProvider(expressionProvider)

        contProvider = CodeContainerProvider(self)
        self.pydebugger.AttachApp(self.app, contProvider) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:debugger.py

示例2: testShellLink

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoCreateInstance [as 别名]
def testShellLink(self):
        desktop = str(shell.SHGetSpecialFolderPath(0, CSIDL_DESKTOP))
        num = 0
        shellLink = pythoncom.CoCreateInstance(shell.CLSID_ShellLink, None, pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink)
        persistFile = shellLink.QueryInterface(pythoncom.IID_IPersistFile)
        names = [os.path.join(desktop, n) for n in os.listdir(desktop)]
        programs = str(shell.SHGetSpecialFolderPath(0, CSIDL_PROGRAMS))
        names.extend([os.path.join(programs, n) for n in os.listdir(programs)])
        for name in names:
            try:
                persistFile.Load(name,STGM_READ)
            except pythoncom.com_error:
                continue
            # Resolve is slow - avoid it for our tests.
            #shellLink.Resolve(0, shell.SLR_ANY_MATCH | shell.SLR_NO_UI)
            fname, findData = shellLink.GetPath(0)
            unc = shellLink.GetPath(shell.SLGP_UNCPRIORITY)[0]
            num += 1
        if num == 0:
            # This isn't a fatal error, but is unlikely.
            print "Could not find any links on your desktop or programs dir, which is unusual" 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:23,代码来源:testShell.py

示例3: TestVTableMI

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoCreateInstance [as 别名]
def TestVTableMI():
    clsctx = pythoncom.CLSCTX_SERVER
    ob = pythoncom.CoCreateInstance("Python.Test.PyCOMTestMI", None, clsctx, pythoncom.IID_IUnknown)
    # This inherits from IStream.
    ob.QueryInterface(pythoncom.IID_IStream)
    # This implements IStorage, specifying the IID as a string
    ob.QueryInterface(pythoncom.IID_IStorage)
    # IDispatch should always work
    ob.QueryInterface(pythoncom.IID_IDispatch)
    
    iid = pythoncom.InterfaceNames["IPyCOMTest"]
    try:
        ob.QueryInterface(iid)
    except TypeError:
        # Python can't actually _use_ this interface yet, so this is
        # "expected".  Any COM error is not.
        pass 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:testPyComTest.py

示例4: __init__

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoCreateInstance [as 别名]
def __init__(self, 
                 path=None,
                 arguments=None, 
                 description=None,
                 workingdir=None,
                 iconpath=None,
                 iconidx=0):
        self._base = pythoncom.CoCreateInstance(
            shell.CLSID_ShellLink, None,
            pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink
        )
        data = map(None, 
                   ['"%s"' % os.path.abspath(path), arguments, description,
                    os.path.abspath(workingdir), os.path.abspath(iconpath)], 
                   ("SetPath", "SetArguments", "SetDescription",
                   "SetWorkingDirectory") )
        for value, function in data:
            if value and function:
                # call function on each non-null value
                getattr(self, function)(value)
        if iconpath:
            self.SetIconLocation(iconpath, iconidx) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:24,代码来源:shortcut.py

示例5: CreateShortCut

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoCreateInstance [as 别名]
def CreateShortCut(Path, Target,Arguments = "", StartIn = "", Icon = ("",0), Description = ""):
    # Get the shell interface.
    sh = pythoncom.CoCreateInstance(shell.CLSID_ShellLink, None, \
        pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink)

    # Get an IPersist interface
    persist = sh.QueryInterface(pythoncom.IID_IPersistFile)

    # Set the data
    sh.SetPath(Target)
    sh.SetDescription(Description)
    sh.SetArguments(Arguments)
    sh.SetWorkingDirectory(StartIn)
    sh.SetIconLocation(Icon[0],Icon[1])
#    sh.SetShowCmd( win32con.SW_SHOWMINIMIZED)

    # Save the link itself.
    persist.Save(Path, 1)
    print "Saved to", Path 
开发者ID:Lithium876,项目名称:ConTroll_Remote_Access_Trojan,代码行数:21,代码来源:testcomext.py

示例6: Get

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoCreateInstance [as 别名]
def Get(cls, filename):
        sh = pythoncom.CoCreateInstance(
            shell.CLSID_ShellLink,
            None,
            pythoncom.CLSCTX_INPROC_SERVER,
            shell.IID_IShellLink
        )
        persist = sh.QueryInterface(pythoncom.IID_IPersistFile).Load(filename)  # NOQA
        self = cls()
        self.path = filename
        self.target = sh.GetPath(shell.SLGP_SHORTPATH)[0]
        self.description = sh.GetDescription()
        self.arguments = sh.GetArguments()
        self.startIn = sh.GetWorkingDirectory()
        self.icons = sh.GetIconLocation()
        return self 
开发者ID:EventGhost,项目名称:EventGhost,代码行数:18,代码来源:Shortcut.py

示例7: __init__

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoCreateInstance [as 别名]
def __init__(self, scriptEngine):
		self.scriptEngine = scriptEngine
		self.adb = adb.Debugger()
		self.rootNode = None
		self.debugApplication = None
		self.ccProvider = documents.CodeContainerProvider()
		try:
			self.scriptSiteDebug = scriptEngine.GetScriptSite(axdebug.IID_IActiveScriptSiteDebug)
		except pythoncom.com_error:
			# No debugger interface (ie, dumb host).  Do the extra work.
			trace("Scripting site has no debugger interface")
			self.scriptSiteDebug = None
		# Get the debug application object.
		self.debugApplication = None
		if self.scriptSiteDebug is not None:
			# Spec says that we should test for this, and if it fails revert to
			# PDM application.
			try:
				self.debugApplication = self.scriptSiteDebug.GetApplication()
				self.rootNode = self.scriptSiteDebug.GetRootApplicationNode()
			except pythoncom.com_error:
				self.debugApplication = None
				
		if self.debugApplication is None:
			# Try to get/create the default one
			# NOTE - Dont catch exceptions here - let the parent do it,
			# so it knows debug support is available.
			pdm=pythoncom.CoCreateInstance(axdebug.CLSID_ProcessDebugManager,None,pythoncom.CLSCTX_ALL, axdebug.IID_IProcessDebugManager)
			self.debugApplication = pdm.GetDefaultApplication()
			self.rootNode = self.debugApplication.GetRootNode()
			
		assert self.debugApplication is not None, "Need to have a DebugApplication object by now!"
		self.activeScriptDebug = None

		if self.debugApplication is not None:
			self.adb.AttachApp(self.debugApplication, self.ccProvider)
		self.codeContainers = {}
		self.activeScriptDebug = _wrap(ActiveScriptDebug(self, self.codeContainers), axdebug.IID_IActiveScriptDebug) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:40,代码来源:debug.py

示例8: __init__

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoCreateInstance [as 别名]
def __init__(self, site, engine):
    self.eScript = self.eParse = self.eSafety = None
    if type(engine) == type(''):
      engine = pythoncom.CoCreateInstance(engine,
                                          None,
                                          pythoncom.CLSCTX_SERVER,
                                          pythoncom.IID_IUnknown)

    self.eScript = engine.QueryInterface(axscript.IID_IActiveScript)
    self.eParse = engine.QueryInterface(axscript.IID_IActiveScriptParse)
    self.eSafety = engine.QueryInterface(axscript.IID_IObjectSafety)

    self.eScript.SetScriptSite(site)
    self.eParse.InitNew() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:16,代码来源:axsite.py

示例9: TestEngine

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoCreateInstance [as 别名]
def TestEngine():
  model = {'Test' : util.wrap(ObjectModel()) }
  scriptDir = "."
  site = MySite(model)
  pyEngine = site._AddEngine("Python")
#  pyEngine2 = site._AddEngine("Python")
  vbEngine = site._AddEngine("VBScript")
#  forthEngine = site._AddEngine("ForthScript")
  try:
#    code = open(os.path.join(scriptDir, "debugTest.4ths"),"rb").read()
#    forthEngine.AddCode(code)
    code = open(os.path.join(scriptDir, "debugTest.pys"),"rb").read()
    pyEngine.AddCode(code)
    code = open(os.path.join(scriptDir, "debugTest.vbs"),"rb").read()
    vbEngine.AddCode(code)
#    code = open(os.path.join(scriptDir, "debugTestFail.pys"),"rb").read()
#    pyEngine2.AddCode(code)

#    from win32com.axdebug import axdebug
#    sessionProvider=pythoncom.CoCreateInstance(axdebug.CLSID_DefaultDebugSessionProvider,None,pythoncom.CLSCTX_ALL, axdebug.IID_IDebugSessionProvider)
#    sessionProvider.StartDebugSession(None)
    
    raw_input("Press enter to continue")
 #   forthEngine.Start()
    pyEngine.Start() # Actually run the Python code
    vbEngine.Start() # Actually run the VB code
  except pythoncom.com_error, details:
    print "Script failed: %s (0x%x)" % (details[1], details[0])
  # Now run the code expected to fail!
#  try:
#    pyEngine2.Start() # Actually run the Python code that fails!
#    print "Script code worked when it should have failed."
#  except pythoncom.com_error:
#    pass 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:36,代码来源:testHost4Dbg.py

示例10: __init__

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoCreateInstance [as 别名]
def __init__( self ):
		self._base = pythoncom.CoCreateInstance(
			shell.CLSID_InternetShortcut, None,
			pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IUniformResourceLocator
		) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:IUniformResourceLocator.py

示例11: __init__

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoCreateInstance [as 别名]
def __init__( self ):
		self._base = pythoncom.CoCreateInstance(
			shell.CLSID_ShellLink, None,
			pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink
		) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:create_link.py

示例12: dumpall

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoCreateInstance [as 别名]
def dumpall():
    dm=pythoncom.CoCreateInstance(axdebug.CLSID_MachineDebugManager,None,pythoncom.CLSCTX_ALL, axdebug.IID_IMachineDebugManager)
    e=Enumerator(dm.EnumApplications())
    for app in e:
        print "Application: %s" % app.GetName()
        node = app.GetRootNode() # of type PyIDebugApplicationNode->PyIDebugDocumentProvider->PyIDebugDocumentInfo
        DumpDebugApplicationNode(node) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:dump.py

示例13: _GetGoodDispatch

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoCreateInstance [as 别名]
def _GetGoodDispatch(IDispatch, clsctx = pythoncom.CLSCTX_SERVER):
	if isinstance(IDispatch, _GoodDispatchTypes):
		try:
			IDispatch = pythoncom.connect(IDispatch)
		except pythoncom.ole_error:
			IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
	else:
		# may already be a wrapped class.
		IDispatch = getattr(IDispatch, "_oleobj_", IDispatch)
	return IDispatch 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:dynamic.py

示例14: GetSubList

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoCreateInstance [as 别名]
def GetSubList(self):
        win32ui.DoWaitCursor(1)
        catid, lcid, desc = self.myobject
        catinf=pythoncom.CoCreateInstance(pythoncom.CLSID_StdComponentCategoriesMgr,None,pythoncom.CLSCTX_INPROC,pythoncom.IID_ICatInformation)
        ret = []
        for clsid in util.Enumerator(catinf.EnumClassesOfCategories((catid,),())):
            ret.append(HLICLSID(clsid))
        win32ui.DoWaitCursor(0)

        return ret 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:combrowse.py

示例15: _cat_registrar

# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import CoCreateInstance [as 别名]
def _cat_registrar():
  return pythoncom.CoCreateInstance(
    pythoncom.CLSID_StdComponentCategoriesMgr,
    None,
    pythoncom.CLSCTX_INPROC_SERVER,
    pythoncom.IID_ICatRegister
    ) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:register.py


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