我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用pythoncom.RegisterTypeLib()。
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)
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)
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)