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

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

项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def BuildTypelib():
    from distutils.dep_util import newer
    this_dir = os.path.dirname(__file__)
    idl = os.path.abspath(os.path.join(this_dir, "pippo.idl"))
    tlb=os.path.splitext(idl)[0] + '.tlb'
    if newer(idl, tlb):
        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 pippo_i.c pippo_p.c pippo.h".split():
            os.remove(os.path.join(this_dir, fname))

    print "Registering %s" % (tlb,)
    tli=pythoncom.LoadTypeLib(tlb)
    pythoncom.RegisterTypeLib(tli,tlb)
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def BuildTypelib():
    from distutils.dep_util import newer
    this_dir = os.path.dirname(__file__)
    idl = os.path.abspath(os.path.join(this_dir, "pippo.idl"))
    tlb=os.path.splitext(idl)[0] + '.tlb'
    if newer(idl, tlb):
        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 pippo_i.c pippo_p.c pippo.h".split():
            os.remove(os.path.join(this_dir, fname))

    print "Registering %s" % (tlb,)
    tli=pythoncom.LoadTypeLib(tlb)
    pythoncom.RegisterTypeLib(tli,tlb)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def BuildTypelib():
    from distutils.dep_util import newer
    this_dir = os.path.dirname(__file__)
    idl = os.path.abspath(os.path.join(this_dir, "pippo.idl"))
    tlb=os.path.splitext(idl)[0] + '.tlb'
    if newer(idl, tlb):
        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 pippo_i.c pippo_p.c pippo.h".split():
            os.remove(os.path.join(this_dir, fname))

    print "Registering %s" % (tlb,)
    tli=pythoncom.LoadTypeLib(tlb)
    pythoncom.RegisterTypeLib(tli,tlb)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def BuildTypelib():
    from distutils.dep_util import newer
    this_dir = os.path.dirname(__file__)
    idl = os.path.abspath(os.path.join(this_dir, "pippo.idl"))
    tlb=os.path.splitext(idl)[0] + '.tlb'
    if newer(idl, tlb):
        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 pippo_i.c pippo_p.c pippo.h".split():
            os.remove(os.path.join(this_dir, fname))

    print("Registering %s" % (tlb,))
    tli=pythoncom.LoadTypeLib(tlb)
    pythoncom.RegisterTypeLib(tli,tlb)
项目: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)