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

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

项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def _wrap_(self, object):
    """Wraps up the specified object.

       This function keeps a reference to the passed
       object, and may interogate it to determine how to respond to COM requests, etc.
    """
    # We "clobber" certain of our own methods with ones
    # provided by the wrapped object, iff they exist.
    self._name_to_dispid_ = { }
    ob = self._obj_ = object
    if hasattr(ob, '_query_interface_'):
      self._query_interface_ = ob._query_interface_

    if hasattr(ob, '_invoke_'):
      self._invoke_ = ob._invoke_

    if hasattr(ob, '_invokeex_'):
      self._invokeex_ = ob._invokeex_

    if hasattr(ob, '_getidsofnames_'):
      self._getidsofnames_ = ob._getidsofnames_

    if hasattr(ob, '_getdispid_'):
      self._getdispid_ = ob._getdispid_

    # Allow for override of certain special attributes.
    if hasattr(ob, '_com_interfaces_'):
      self._com_interfaces_ = []
      # Allow interfaces to be specified by name.
      for i in ob._com_interfaces_:
        if type(i) != pywintypes.IIDType:
          # Prolly a string!
          if i[0] != "{":
            i = pythoncom.InterfaceNames[i]
          else:
            i = pythoncom.MakeIID(i)
        self._com_interfaces_.append(i)
    else:
      self._com_interfaces_ = [ ]

  # "QueryInterface" handling.
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def __init__(self, myobject, name=None ):
        if type(myobject)==type(''):
            myobject = pythoncom.MakeIID(myobject)
        if name is None:
            try:
                name = pythoncom.ProgIDFromCLSID(myobject)
            except pythoncom.com_error:
                name = str(myobject)
            name = "IID: " + name
        HLICOM.__init__(self, myobject, name)
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def testComplex(self):
        clsid = pythoncom.MakeIID("{CD637886-DB8B-4b04-98B5-25731E1495BE}")
        ctime, atime, wtime = self._getTestTimes()
        d = dict(cFileName="foo.txt",
                 clsid=clsid,
                 sizel=(1,2),
                 pointl=(3,4),
                 dwFileAttributes = win32con.FILE_ATTRIBUTE_NORMAL,
                 ftCreationTime=ctime,
                 ftLastAccessTime=atime,
                 ftLastWriteTime=wtime,
                 nFileSize=sys_maxsize + 1)
        self._testRT(d)
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def _wrap_(self, object):
    """Wraps up the specified object.

       This function keeps a reference to the passed
       object, and may interogate it to determine how to respond to COM requests, etc.
    """
    # We "clobber" certain of our own methods with ones
    # provided by the wrapped object, iff they exist.
    self._name_to_dispid_ = { }
    ob = self._obj_ = object
    if hasattr(ob, '_query_interface_'):
      self._query_interface_ = ob._query_interface_

    if hasattr(ob, '_invoke_'):
      self._invoke_ = ob._invoke_

    if hasattr(ob, '_invokeex_'):
      self._invokeex_ = ob._invokeex_

    if hasattr(ob, '_getidsofnames_'):
      self._getidsofnames_ = ob._getidsofnames_

    if hasattr(ob, '_getdispid_'):
      self._getdispid_ = ob._getdispid_

    # Allow for override of certain special attributes.
    if hasattr(ob, '_com_interfaces_'):
      self._com_interfaces_ = []
      # Allow interfaces to be specified by name.
      for i in ob._com_interfaces_:
        if type(i) != pywintypes.IIDType:
          # Prolly a string!
          if i[0] != "{":
            i = pythoncom.InterfaceNames[i]
          else:
            i = pythoncom.MakeIID(i)
        self._com_interfaces_.append(i)
    else:
      self._com_interfaces_ = [ ]

  # "QueryInterface" handling.
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def __init__(self, myobject, name=None ):
        if type(myobject)==type(''):
            myobject = pythoncom.MakeIID(myobject)
        if name is None:
            try:
                name = pythoncom.ProgIDFromCLSID(myobject)
            except pythoncom.com_error:
                name = str(myobject)
            name = "IID: " + name
        HLICOM.__init__(self, myobject, name)
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def testComplex(self):
        clsid = pythoncom.MakeIID("{CD637886-DB8B-4b04-98B5-25731E1495BE}")
        ctime, atime, wtime = self._getTestTimes()
        d = dict(cFileName="foo.txt",
                 clsid=clsid,
                 sizel=(1,2),
                 pointl=(3,4),
                 dwFileAttributes = win32con.FILE_ATTRIBUTE_NORMAL,
                 ftCreationTime=ctime,
                 ftLastAccessTime=atime,
                 ftLastWriteTime=wtime,
                 nFileSize=sys_maxsize + 1)
        self._testRT(d)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def _wrap_(self, object):
    """Wraps up the specified object.

       This function keeps a reference to the passed
       object, and may interogate it to determine how to respond to COM requests, etc.
    """
    # We "clobber" certain of our own methods with ones
    # provided by the wrapped object, iff they exist.
    self._name_to_dispid_ = { }
    ob = self._obj_ = object
    if hasattr(ob, '_query_interface_'):
      self._query_interface_ = ob._query_interface_

    if hasattr(ob, '_invoke_'):
      self._invoke_ = ob._invoke_

    if hasattr(ob, '_invokeex_'):
      self._invokeex_ = ob._invokeex_

    if hasattr(ob, '_getidsofnames_'):
      self._getidsofnames_ = ob._getidsofnames_

    if hasattr(ob, '_getdispid_'):
      self._getdispid_ = ob._getdispid_

    # Allow for override of certain special attributes.
    if hasattr(ob, '_com_interfaces_'):
      self._com_interfaces_ = []
      # Allow interfaces to be specified by name.
      for i in ob._com_interfaces_:
        if type(i) != pywintypes.IIDType:
          # Prolly a string!
          if i[0] != "{":
            i = pythoncom.InterfaceNames[i]
          else:
            i = pythoncom.MakeIID(i)
        self._com_interfaces_.append(i)
    else:
      self._com_interfaces_ = [ ]

  # "QueryInterface" handling.
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def __init__(self, myobject, name=None ):
        if type(myobject)==type(''):
            myobject = pythoncom.MakeIID(myobject)
        if name is None:
            try:
                name = pythoncom.ProgIDFromCLSID(myobject)
            except pythoncom.com_error:
                name = str(myobject)
            name = "IID: " + name
        HLICOM.__init__(self, myobject, name)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def testComplex(self):
        clsid = pythoncom.MakeIID("{CD637886-DB8B-4b04-98B5-25731E1495BE}")
        ctime, atime, wtime = self._getTestTimes()
        d = dict(cFileName="foo.txt",
                 clsid=clsid,
                 sizel=(1,2),
                 pointl=(3,4),
                 dwFileAttributes = win32con.FILE_ATTRIBUTE_NORMAL,
                 ftCreationTime=ctime,
                 ftLastAccessTime=atime,
                 ftLastWriteTime=wtime,
                 nFileSize=sys_maxsize + 1)
        self._testRT(d)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def _wrap_(self, object):
    """Wraps up the specified object.

       This function keeps a reference to the passed
       object, and may interogate it to determine how to respond to COM requests, etc.
    """
    # We "clobber" certain of our own methods with ones
    # provided by the wrapped object, iff they exist.
    self._name_to_dispid_ = { }
    ob = self._obj_ = object
    if hasattr(ob, '_query_interface_'):
      self._query_interface_ = ob._query_interface_

    if hasattr(ob, '_invoke_'):
      self._invoke_ = ob._invoke_

    if hasattr(ob, '_invokeex_'):
      self._invokeex_ = ob._invokeex_

    if hasattr(ob, '_getidsofnames_'):
      self._getidsofnames_ = ob._getidsofnames_

    if hasattr(ob, '_getdispid_'):
      self._getdispid_ = ob._getdispid_

    # Allow for override of certain special attributes.
    if hasattr(ob, '_com_interfaces_'):
      self._com_interfaces_ = []
      # Allow interfaces to be specified by name.
      for i in ob._com_interfaces_:
        if type(i) != pywintypes.IIDType:
          # Prolly a string!
          if i[0] != "{":
            i = pythoncom.InterfaceNames[i]
          else:
            i = pythoncom.MakeIID(i)
        self._com_interfaces_.append(i)
    else:
      self._com_interfaces_ = [ ]

  # "QueryInterface" handling.
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def __init__(self, myobject, name=None ):
        if type(myobject)==type(''):
            myobject = pythoncom.MakeIID(myobject)
        if name is None:
            try:
                name = pythoncom.ProgIDFromCLSID(myobject)
            except pythoncom.com_error:
                name = str(myobject)
            name = "IID: " + name
        HLICOM.__init__(self, myobject, name)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def testComplex(self):
        clsid = pythoncom.MakeIID("{CD637886-DB8B-4b04-98B5-25731E1495BE}")
        ctime, atime, wtime = self._getTestTimes()
        d = dict(cFileName="foo.txt",
                 clsid=clsid,
                 sizel=(1,2),
                 pointl=(3,4),
                 dwFileAttributes = win32con.FILE_ATTRIBUTE_NORMAL,
                 ftCreationTime=ctime,
                 ftLastAccessTime=atime,
                 ftLastWriteTime=wtime,
                 nFileSize=sys_maxsize + 1)
        self._testRT(d)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def RegisterPythonServer(filename, progids=None, verbose=0):
    if progids:
        if isinstance(progids, str):
            progids = [progids]
        # we know the CLSIDs we need, but we might not be an admin user
        # and otherwise unable to register them.  So as long as the progids
        # exist and the DLL points at our version, assume it already is.
        why_not = None
        for progid in progids:
            try:
                clsid = pythoncom.MakeIID(progid)
            except pythoncom.com_error:
                # no progid - not registered.
                break
            # have a CLSID - open it.
            try:
                HKCR = winreg.HKEY_CLASSES_ROOT
                hk = winreg.OpenKey(HKCR, "CLSID\\%s" % clsid)
                dll = winreg.QueryValue(hk, "InprocServer32")
            except WindowsError:
                # no CLSID or InProcServer32 - not good!
                break
            ok_files = [os.path.basename(pythoncom.__file__),
                        'pythoncomloader%d%d.dll' % (sys.version_info[0], sys.version_info[1])]
            if os.path.basename(dll) not in ok_files:
                why_not = "%r is registered against a different Python version (%s)" % (progid, dll)
                break
        else:
            #print "Skipping registration of '%s' - already registered" % filename
            return
    # needs registration - see if its likely!
    try:
        from win32com.shell.shell import IsUserAnAdmin
    except ImportError:
        print("Can't import win32com.shell - no idea if you are an admin or not?")
        is_admin = False
    else:
        try:
            is_admin = IsUserAnAdmin()
        except pythoncom.com_error:
            # old, less-secure OS - assume *is* admin.
            is_admin = True
    if not is_admin:
        msg = "%r isn't registered, but I'm not an administrator who can register it." % progids[0]
        if why_not:
            msg += "\n(registration check failed as %s)" % why_not
        # throw a normal "class not registered" exception - we don't report
        # them the same way as "real" errors.
        raise pythoncom.com_error(winerror.CO_E_CLASSSTRING, msg, None, -1)
    # so theoretically we are able to register it.
    cmd = '%s "%s" --unattended > nul 2>&1' % (win32api.GetModuleFileName(0), filename)
    if verbose:
        print("Registering engine", filename)
#       print cmd
    rc = os.system(cmd)
    if rc:
        print("Registration command was:")
        print(cmd)
        raise RuntimeError("Registration of engine '%s' failed" % filename)
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def RegisterPythonServer(filename, progids=None, verbose=0):
    if progids:
        if isinstance(progids, basestring):
            progids = [progids]
        # we know the CLSIDs we need, but we might not be an admin user
        # and otherwise unable to register them.  So as long as the progids
        # exist and the DLL points at our version, assume it already is.
        why_not = None
        for progid in progids:
            try:
                clsid = pythoncom.MakeIID(progid)
            except pythoncom.com_error:
                # no progid - not registered.
                break
            # have a CLSID - open it.
            try:
                HKCR = _winreg.HKEY_CLASSES_ROOT
                hk = _winreg.OpenKey(HKCR, "CLSID\\%s" % clsid)
                dll = _winreg.QueryValue(hk, "InprocServer32")
            except WindowsError:
                # no CLSID or InProcServer32 - not good!
                break
            ok_files = [os.path.basename(pythoncom.__file__),
                        'pythoncomloader%d%d.dll' % (sys.version_info[0], sys.version_info[1])]
            if os.path.basename(dll) not in ok_files:
                why_not = "%r is registered against a different Python version (%s)" % (progid, dll)
                break
        else:
            #print "Skipping registration of '%s' - already registered" % filename
            return
    # needs registration - see if its likely!
    try:
        from win32com.shell.shell import IsUserAnAdmin
    except ImportError:
        print "Can't import win32com.shell - no idea if you are an admin or not?"
        is_admin = False
    else:
        try:
            is_admin = IsUserAnAdmin()
        except pythoncom.com_error:
            # old, less-secure OS - assume *is* admin.
            is_admin = True
    if not is_admin:
        msg = "%r isn't registered, but I'm not an administrator who can register it." % progids[0]
        if why_not:
            msg += "\n(registration check failed as %s)" % why_not
        # throw a normal "class not registered" exception - we don't report
        # them the same way as "real" errors.
        raise pythoncom.com_error(winerror.CO_E_CLASSSTRING, msg, None, -1)
    # so theoretically we are able to register it.
    cmd = '%s "%s" --unattended > nul 2>&1' % (win32api.GetModuleFileName(0), filename)
    if verbose:
        print "Registering engine", filename
#       print cmd
    rc = os.system(cmd)
    if rc:
        print "Registration command was:"
        print cmd
        raise RuntimeError("Registration of engine '%s' failed" % filename)
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def RegisterPythonServer(filename, progids=None, verbose=0):
    if progids:
        if isinstance(progids, basestring):
            progids = [progids]
        # we know the CLSIDs we need, but we might not be an admin user
        # and otherwise unable to register them.  So as long as the progids
        # exist and the DLL points at our version, assume it already is.
        why_not = None
        for progid in progids:
            try:
                clsid = pythoncom.MakeIID(progid)
            except pythoncom.com_error:
                # no progid - not registered.
                break
            # have a CLSID - open it.
            try:
                HKCR = _winreg.HKEY_CLASSES_ROOT
                hk = _winreg.OpenKey(HKCR, "CLSID\\%s" % clsid)
                dll = _winreg.QueryValue(hk, "InprocServer32")
            except WindowsError:
                # no CLSID or InProcServer32 - not good!
                break
            ok_files = [os.path.basename(pythoncom.__file__),
                        'pythoncomloader%d%d.dll' % (sys.version_info[0], sys.version_info[1])]
            if os.path.basename(dll) not in ok_files:
                why_not = "%r is registered against a different Python version (%s)" % (progid, dll)
                break
        else:
            #print "Skipping registration of '%s' - already registered" % filename
            return
    # needs registration - see if its likely!
    try:
        from win32com.shell.shell import IsUserAnAdmin
    except ImportError:
        print "Can't import win32com.shell - no idea if you are an admin or not?"
        is_admin = False
    else:
        try:
            is_admin = IsUserAnAdmin()
        except pythoncom.com_error:
            # old, less-secure OS - assume *is* admin.
            is_admin = True
    if not is_admin:
        msg = "%r isn't registered, but I'm not an administrator who can register it." % progids[0]
        if why_not:
            msg += "\n(registration check failed as %s)" % why_not
        # throw a normal "class not registered" exception - we don't report
        # them the same way as "real" errors.
        raise pythoncom.com_error(winerror.CO_E_CLASSSTRING, msg, None, -1)
    # so theoretically we are able to register it.
    cmd = '%s "%s" --unattended > nul 2>&1' % (win32api.GetModuleFileName(0), filename)
    if verbose:
        print "Registering engine", filename
#       print cmd
    rc = os.system(cmd)
    if rc:
        print "Registration command was:"
        print cmd
        raise RuntimeError("Registration of engine '%s' failed" % filename)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def RegisterPythonServer(filename, progids=None, verbose=0):
    if progids:
        if isinstance(progids, basestring):
            progids = [progids]
        # we know the CLSIDs we need, but we might not be an admin user
        # and otherwise unable to register them.  So as long as the progids
        # exist and the DLL points at our version, assume it already is.
        why_not = None
        for progid in progids:
            try:
                clsid = pythoncom.MakeIID(progid)
            except pythoncom.com_error:
                # no progid - not registered.
                break
            # have a CLSID - open it.
            try:
                HKCR = _winreg.HKEY_CLASSES_ROOT
                hk = _winreg.OpenKey(HKCR, "CLSID\\%s" % clsid)
                dll = _winreg.QueryValue(hk, "InprocServer32")
            except WindowsError:
                # no CLSID or InProcServer32 - not good!
                break
            ok_files = [os.path.basename(pythoncom.__file__),
                        'pythoncomloader%d%d.dll' % (sys.version_info[0], sys.version_info[1])]
            if os.path.basename(dll) not in ok_files:
                why_not = "%r is registered against a different Python version (%s)" % (progid, dll)
                break
        else:
            #print "Skipping registration of '%s' - already registered" % filename
            return
    # needs registration - see if its likely!
    try:
        from win32com.shell.shell import IsUserAnAdmin
    except ImportError:
        print "Can't import win32com.shell - no idea if you are an admin or not?"
        is_admin = False
    else:
        try:
            is_admin = IsUserAnAdmin()
        except pythoncom.com_error:
            # old, less-secure OS - assume *is* admin.
            is_admin = True
    if not is_admin:
        msg = "%r isn't registered, but I'm not an administrator who can register it." % progids[0]
        if why_not:
            msg += "\n(registration check failed as %s)" % why_not
        # throw a normal "class not registered" exception - we don't report
        # them the same way as "real" errors.
        raise pythoncom.com_error(winerror.CO_E_CLASSSTRING, msg, None, -1)
    # so theoretically we are able to register it.
    cmd = '%s "%s" --unattended > nul 2>&1' % (win32api.GetModuleFileName(0), filename)
    if verbose:
        print "Registering engine", filename
#       print cmd
    rc = os.system(cmd)
    if rc:
        print "Registration command was:"
        print cmd
        raise RuntimeError("Registration of engine '%s' failed" % filename)