Compile and register the typelib
(self)
| 41 | return "\n".join((header, body, footer)) |
| 42 | |
| 43 | def compile(self): |
| 44 | """Compile and register the typelib""" |
| 45 | code = str(self) |
| 46 | curdir = os.path.dirname(__file__) |
| 47 | idl_path = os.path.join(curdir, "mylib.idl") |
| 48 | tlb_path = os.path.join(curdir, "mylib.tlb") |
| 49 | if not os.path.isfile(idl_path) or open(idl_path, "r").read() != code: |
| 50 | open(idl_path, "w").write(code) |
| 51 | os.system( |
| 52 | r'call "%%VS71COMNTOOLS%%vsvars32.bat" && ' |
| 53 | r"midl /nologo %s /tlb %s" % (idl_path, tlb_path) |
| 54 | ) |
| 55 | # Register the typelib... |
| 56 | tlib = comtypes.typeinfo.LoadTypeLib(tlb_path) |
| 57 | # create the wrapper module... |
| 58 | comtypes.client.GetModule(tlb_path) |
| 59 | # Unregister the typelib at interpreter exit... |
| 60 | attr = tlib.GetLibAttr() |
| 61 | guid, major, minor = attr.guid, attr.wMajorVerNum, attr.wMinorVerNum |
| 62 | ## atexit.register(comtypes.typeinfo.UnRegisterTypeLib, |
| 63 | ## guid, major, minor) |
| 64 | return tlb_path |
| 65 | |
| 66 | |
| 67 | class Interface: |
no test coverage detected