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

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

项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def Resolve(self):
        if self.dll is None:
            return 0
        tlb = pythoncom.LoadTypeLib(self.dll)
        self.FromTypelib(tlb, None)
        return 1
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def __init__(self, typefile = None):
        TypeBrowseDialog_Parent.__init__(self, self.GetTemplate())
        try:
            if typefile:
                self.tlb = pythoncom.LoadTypeLib(typefile)
            else:
                self.tlb = None
        except pythoncom.ole_error:
            self.MessageBox("The file does not contain type information")
            self.tlb = None
        self.HookCommand(self.CmdTypeListbox, self.IDC_TYPELIST)
        self.HookCommand(self.CmdMemberListbox, self.IDC_MEMBERLIST)
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def OnFileOpen(self, id, code):
        openFlags = win32con.OFN_OVERWRITEPROMPT | win32con.OFN_FILEMUSTEXIST
        fspec = "Type Libraries (*.tlb, *.olb)|*.tlb;*.olb|OCX Files (*.ocx)|*.ocx|DLL's (*.dll)|*.dll|All Files (*.*)|*.*||"
        dlg = win32ui.CreateFileDialog(1, None, None, openFlags, fspec)
        if dlg.DoModal() == win32con.IDOK:
            try:
                self.tlb = pythoncom.LoadTypeLib(dlg.GetPathName())
            except pythoncom.ole_error:
                self.MessageBox("The file does not contain type information")
                self.tlb = None
            self._SetupTLB()
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def GetSubList(self):
        ret = []
        ret.append(browser.MakeHLI(self.myobject, "Filename"))
        try:
            tlb = pythoncom.LoadTypeLib(self.myobject)
        except pythoncom.com_error:
            return [browser.MakeHLI("%s can not be loaded" % self.myobject)]

        for i in range(tlb.GetTypeInfoCount()):
            try:
                ret.append(HLITypeKinds[tlb.GetTypeInfoType(i)][0]( (tlb, i) ) )
            except pythoncom.com_error:
                ret.append(browser.MakeHLI("The type info can not be loaded!"))
        ret.sort()
        return ret
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def Resolve(self):
        if self.dll is None:
            return 0
        tlb = pythoncom.LoadTypeLib(self.dll)
        self.FromTypelib(tlb, None)
        return 1
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def __init__(self, typefile = None):
        TypeBrowseDialog_Parent.__init__(self, self.GetTemplate())
        try:
            if typefile:
                self.tlb = pythoncom.LoadTypeLib(typefile)
            else:
                self.tlb = None
        except pythoncom.ole_error:
            self.MessageBox("The file does not contain type information")
            self.tlb = None
        self.HookCommand(self.CmdTypeListbox, self.IDC_TYPELIST)
        self.HookCommand(self.CmdMemberListbox, self.IDC_MEMBERLIST)
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def OnFileOpen(self, id, code):
        openFlags = win32con.OFN_OVERWRITEPROMPT | win32con.OFN_FILEMUSTEXIST
        fspec = "Type Libraries (*.tlb, *.olb)|*.tlb;*.olb|OCX Files (*.ocx)|*.ocx|DLL's (*.dll)|*.dll|All Files (*.*)|*.*||"
        dlg = win32ui.CreateFileDialog(1, None, None, openFlags, fspec)
        if dlg.DoModal() == win32con.IDOK:
            try:
                self.tlb = pythoncom.LoadTypeLib(dlg.GetPathName())
            except pythoncom.ole_error:
                self.MessageBox("The file does not contain type information")
                self.tlb = None
            self._SetupTLB()
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def GetSubList(self):
        ret = []
        ret.append(browser.MakeHLI(self.myobject, "Filename"))
        try:
            tlb = pythoncom.LoadTypeLib(self.myobject)
        except pythoncom.com_error:
            return [browser.MakeHLI("%s can not be loaded" % self.myobject)]

        for i in range(tlb.GetTypeInfoCount()):
            try:
                ret.append(HLITypeKinds[tlb.GetTypeInfoType(i)][0]( (tlb, i) ) )
            except pythoncom.com_error:
                ret.append(browser.MakeHLI("The type info can not be loaded!"))
        ret.sort()
        return ret
项目:rdkit4excel    作者:janholstjensen    | 项目源码 | 文件源码
def BuildTypelib(idlfile = "RDKitXL.idl"):
    this_dir = os.path.dirname(__file__)
    idl = os.path.abspath(os.path.join(this_dir, idlfile))
    basename = idlfile.split('.')[0]
    tlb=os.path.splitext(idl)[0] + '.tlb'
    prev_idl = idl + ".previous"

    this_idl_txt = "".join(open(idl, 'r').readlines())
    previous_idl_txt = "does not exist"
    if os.path.isfile(prev_idl):
        previous_idl_txt = "".join(open(prev_idl, 'r').readlines())

    if this_idl_txt != previous_idl_txt:
        print("Compiling %s." % (idl,))
        rc = os.system ('midl "%s"' % (idl,))
        if rc:
            raise RuntimeError("Compiling MIDL failed!")
        # Can't work out how to prevent MIDL from generating the stubs.
        # just nuke them
        for fname in ("dlldata.c %s_i.c %s_p.c %s.h"%(basename, basename, basename)).split():
            os.remove(os.path.join(this_dir, fname))
        open(prev_idl, 'w').write("".join(open(idl, 'r').readlines()))

    else:
        print("No IDL changes.")

    print("Registering %s." % (tlb,))
    tli=pythoncom.LoadTypeLib(tlb)
    pythoncom.RegisterTypeLib(tli,tlb)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def Resolve(self):
        if self.dll is None:
            return 0
        tlb = pythoncom.LoadTypeLib(self.dll)
        self.FromTypelib(tlb, None)
        return 1
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def __init__(self, typefile = None):
        TypeBrowseDialog_Parent.__init__(self, self.GetTemplate())
        try:
            if typefile:
                self.tlb = pythoncom.LoadTypeLib(typefile)
            else:
                self.tlb = None
        except pythoncom.ole_error:
            self.MessageBox("The file does not contain type information")
            self.tlb = None
        self.HookCommand(self.CmdTypeListbox, self.IDC_TYPELIST)
        self.HookCommand(self.CmdMemberListbox, self.IDC_MEMBERLIST)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def OnFileOpen(self, id, code):
        openFlags = win32con.OFN_OVERWRITEPROMPT | win32con.OFN_FILEMUSTEXIST
        fspec = "Type Libraries (*.tlb, *.olb)|*.tlb;*.olb|OCX Files (*.ocx)|*.ocx|DLL's (*.dll)|*.dll|All Files (*.*)|*.*||"
        dlg = win32ui.CreateFileDialog(1, None, None, openFlags, fspec)
        if dlg.DoModal() == win32con.IDOK:
            try:
                self.tlb = pythoncom.LoadTypeLib(dlg.GetPathName())
            except pythoncom.ole_error:
                self.MessageBox("The file does not contain type information")
                self.tlb = None
            self._SetupTLB()
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def GetSubList(self):
        ret = []
        ret.append(browser.MakeHLI(self.myobject, "Filename"))
        try:
            tlb = pythoncom.LoadTypeLib(self.myobject)
        except pythoncom.com_error:
            return [browser.MakeHLI("%s can not be loaded" % self.myobject)]

        for i in range(tlb.GetTypeInfoCount()):
            try:
                ret.append(HLITypeKinds[tlb.GetTypeInfoType(i)][0]( (tlb, i) ) )
            except pythoncom.com_error:
                ret.append(browser.MakeHLI("The type info can not be loaded!"))
        ret.sort()
        return ret
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def Resolve(self):
        if self.dll is None:
            return 0
        tlb = pythoncom.LoadTypeLib(self.dll)
        self.FromTypelib(tlb, None)
        return 1
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def __init__(self, typefile = None):
        TypeBrowseDialog_Parent.__init__(self, self.GetTemplate())
        try:
            if typefile:
                self.tlb = pythoncom.LoadTypeLib(typefile)
            else:
                self.tlb = None
        except pythoncom.ole_error:
            self.MessageBox("The file does not contain type information")
            self.tlb = None
        self.HookCommand(self.CmdTypeListbox, self.IDC_TYPELIST)
        self.HookCommand(self.CmdMemberListbox, self.IDC_MEMBERLIST)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def OnFileOpen(self, id, code):
        openFlags = win32con.OFN_OVERWRITEPROMPT | win32con.OFN_FILEMUSTEXIST
        fspec = "Type Libraries (*.tlb, *.olb)|*.tlb;*.olb|OCX Files (*.ocx)|*.ocx|DLL's (*.dll)|*.dll|All Files (*.*)|*.*||"
        dlg = win32ui.CreateFileDialog(1, None, None, openFlags, fspec)
        if dlg.DoModal() == win32con.IDOK:
            try:
                self.tlb = pythoncom.LoadTypeLib(dlg.GetPathName())
            except pythoncom.ole_error:
                self.MessageBox("The file does not contain type information")
                self.tlb = None
            self._SetupTLB()
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def GetSubList(self):
        ret = []
        ret.append(browser.MakeHLI(self.myobject, "Filename"))
        try:
            tlb = pythoncom.LoadTypeLib(self.myobject)
        except pythoncom.com_error:
            return [browser.MakeHLI("%s can not be loaded" % self.myobject)]

        for i in range(tlb.GetTypeInfoCount()):
            try:
                ret.append(HLITypeKinds[tlb.GetTypeInfoType(i)][0]( (tlb, i) ) )
            except pythoncom.com_error:
                ret.append(browser.MakeHLI("The type info can not be loaded!"))
        ret.sort()
        return ret
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def GetTypeLibsForSpec(arg):
    """Given an argument on the command line (either a file name, library
    description, or ProgID of an object) return a list of actual typelibs
    to use. """
    typelibs = []
    try:
        try:
            tlb = pythoncom.LoadTypeLib(arg)
            spec = selecttlb.TypelibSpec(None, 0,0,0)
            spec.FromTypelib(tlb, arg)
            typelibs.append((tlb, spec))
        except pythoncom.com_error:
            # See if it is a description
            tlbs = selecttlb.FindTlbsWithDescription(arg)
            if len(tlbs)==0:
                # Maybe it is the name of a COM object?
                try:
                    ob = Dispatch(arg)
                    # and if so, it must support typelib info
                    tlb, index = ob._oleobj_.GetTypeInfo().GetContainingTypeLib()
                    spec = selecttlb.TypelibSpec(None, 0,0,0)
                    spec.FromTypelib(tlb)
                    tlbs.append(spec)
                except pythoncom.com_error:
                    pass
            if len(tlbs)==0:
                print "Could not locate a type library matching '%s'" % (arg)
            for spec in tlbs:
                # Version numbers not always reliable if enumerated from registry.
                # (as some libs use hex, other's dont.  Both examples from MS, of course.)
                if spec.dll is None:
                    tlb = pythoncom.LoadRegTypeLib(spec.clsid, spec.major, spec.minor, spec.lcid)
                else:
                    tlb = pythoncom.LoadTypeLib(spec.dll)

                # We have a typelib, but it may not be exactly what we specified
                # (due to automatic version matching of COM).  So we query what we really have!
                attr = tlb.GetLibAttr()
                spec.major = attr[3]
                spec.minor = attr[4]
                spec.lcid = attr[1]
                typelibs.append((tlb, spec))
        return typelibs
    except pythoncom.com_error:
        t,v,tb=sys.exc_info()
        sys.stderr.write ("Unable to load type library from '%s' - %s\n" % (arg, v))
        tb = None # Storing tb in a local is a cycle!
        sys.exit(1)
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def GetTypeLibsForSpec(arg):
    """Given an argument on the command line (either a file name, library
    description, or ProgID of an object) return a list of actual typelibs
    to use. """
    typelibs = []
    try:
        try:
            tlb = pythoncom.LoadTypeLib(arg)
            spec = selecttlb.TypelibSpec(None, 0,0,0)
            spec.FromTypelib(tlb, arg)
            typelibs.append((tlb, spec))
        except pythoncom.com_error:
            # See if it is a description
            tlbs = selecttlb.FindTlbsWithDescription(arg)
            if len(tlbs)==0:
                # Maybe it is the name of a COM object?
                try:
                    ob = Dispatch(arg)
                    # and if so, it must support typelib info
                    tlb, index = ob._oleobj_.GetTypeInfo().GetContainingTypeLib()
                    spec = selecttlb.TypelibSpec(None, 0,0,0)
                    spec.FromTypelib(tlb)
                    tlbs.append(spec)
                except pythoncom.com_error:
                    pass
            if len(tlbs)==0:
                print "Could not locate a type library matching '%s'" % (arg)
            for spec in tlbs:
                # Version numbers not always reliable if enumerated from registry.
                # (as some libs use hex, other's dont.  Both examples from MS, of course.)
                if spec.dll is None:
                    tlb = pythoncom.LoadRegTypeLib(spec.clsid, spec.major, spec.minor, spec.lcid)
                else:
                    tlb = pythoncom.LoadTypeLib(spec.dll)

                # We have a typelib, but it may not be exactly what we specified
                # (due to automatic version matching of COM).  So we query what we really have!
                attr = tlb.GetLibAttr()
                spec.major = attr[3]
                spec.minor = attr[4]
                spec.lcid = attr[1]
                typelibs.append((tlb, spec))
        return typelibs
    except pythoncom.com_error:
        t,v,tb=sys.exc_info()
        sys.stderr.write ("Unable to load type library from '%s' - %s\n" % (arg, v))
        tb = None # Storing tb in a local is a cycle!
        sys.exit(1)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def GetTypeLibsForSpec(arg):
    """Given an argument on the command line (either a file name, library
    description, or ProgID of an object) return a list of actual typelibs
    to use. """
    typelibs = []
    try:
        try:
            tlb = pythoncom.LoadTypeLib(arg)
            spec = selecttlb.TypelibSpec(None, 0,0,0)
            spec.FromTypelib(tlb, arg)
            typelibs.append((tlb, spec))
        except pythoncom.com_error:
            # See if it is a description
            tlbs = selecttlb.FindTlbsWithDescription(arg)
            if len(tlbs)==0:
                # Maybe it is the name of a COM object?
                try:
                    ob = Dispatch(arg)
                    # and if so, it must support typelib info
                    tlb, index = ob._oleobj_.GetTypeInfo().GetContainingTypeLib()
                    spec = selecttlb.TypelibSpec(None, 0,0,0)
                    spec.FromTypelib(tlb)
                    tlbs.append(spec)
                except pythoncom.com_error:
                    pass
            if len(tlbs)==0:
                print "Could not locate a type library matching '%s'" % (arg)
            for spec in tlbs:
                # Version numbers not always reliable if enumerated from registry.
                # (as some libs use hex, other's dont.  Both examples from MS, of course.)
                if spec.dll is None:
                    tlb = pythoncom.LoadRegTypeLib(spec.clsid, spec.major, spec.minor, spec.lcid)
                else:
                    tlb = pythoncom.LoadTypeLib(spec.dll)

                # We have a typelib, but it may not be exactly what we specified
                # (due to automatic version matching of COM).  So we query what we really have!
                attr = tlb.GetLibAttr()
                spec.major = attr[3]
                spec.minor = attr[4]
                spec.lcid = attr[1]
                typelibs.append((tlb, spec))
        return typelibs
    except pythoncom.com_error:
        t,v,tb=sys.exc_info()
        sys.stderr.write ("Unable to load type library from '%s' - %s\n" % (arg, v))
        tb = None # Storing tb in a local is a cycle!
        sys.exit(1)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def GetTypeLibsForSpec(arg):
    """Given an argument on the command line (either a file name, library
    description, or ProgID of an object) return a list of actual typelibs
    to use. """
    typelibs = []
    try:
        try:
            tlb = pythoncom.LoadTypeLib(arg)
            spec = selecttlb.TypelibSpec(None, 0,0,0)
            spec.FromTypelib(tlb, arg)
            typelibs.append((tlb, spec))
        except pythoncom.com_error:
            # See if it is a description
            tlbs = selecttlb.FindTlbsWithDescription(arg)
            if len(tlbs)==0:
                # Maybe it is the name of a COM object?
                try:
                    ob = Dispatch(arg)
                    # and if so, it must support typelib info
                    tlb, index = ob._oleobj_.GetTypeInfo().GetContainingTypeLib()
                    spec = selecttlb.TypelibSpec(None, 0,0,0)
                    spec.FromTypelib(tlb)
                    tlbs.append(spec)
                except pythoncom.com_error:
                    pass
            if len(tlbs)==0:
                print("Could not locate a type library matching '%s'" % (arg))
            for spec in tlbs:
                # Version numbers not always reliable if enumerated from registry.
                # (as some libs use hex, other's dont.  Both examples from MS, of course.)
                if spec.dll is None:
                    tlb = pythoncom.LoadRegTypeLib(spec.clsid, spec.major, spec.minor, spec.lcid)
                else:
                    tlb = pythoncom.LoadTypeLib(spec.dll)

                # We have a typelib, but it may not be exactly what we specified
                # (due to automatic version matching of COM).  So we query what we really have!
                attr = tlb.GetLibAttr()
                spec.major = attr[3]
                spec.minor = attr[4]
                spec.lcid = attr[1]
                typelibs.append((tlb, spec))
        return typelibs
    except pythoncom.com_error:
        t,v,tb=sys.exc_info()
        sys.stderr.write ("Unable to load type library from '%s' - %s\n" % (arg, v))
        tb = None # Storing tb in a local is a cycle!
        sys.exit(1)