Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

combrowse.py 20KB

1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. """A utility for browsing COM objects.
  2. Usage:
  3. Command Prompt
  4. Use the command *"python.exe combrowse.py"*. This will display
  5. display a fairly small, modal dialog.
  6. Pythonwin
  7. Use the "Run Script" menu item, and this will create the browser in an
  8. MDI window. This window can be fully resized.
  9. Details
  10. This module allows browsing of registered Type Libraries, COM categories,
  11. and running COM objects. The display is similar to the Pythonwin object
  12. browser, and displays the objects in a hierarchical window.
  13. Note that this module requires the win32ui (ie, Pythonwin) distribution to
  14. work.
  15. """
  16. import sys
  17. import pythoncom
  18. import win32api
  19. import win32con
  20. import win32ui
  21. from pywin.tools import browser
  22. from win32com.client import util
  23. class HLIRoot(browser.HLIPythonObject):
  24. def __init__(self, title):
  25. super().__init__(name=title)
  26. def GetSubList(self):
  27. return [
  28. HLIHeadingCategory(),
  29. HLI_IEnumMoniker(
  30. pythoncom.GetRunningObjectTable().EnumRunning(), "Running Objects"
  31. ),
  32. HLIHeadingRegisterdTypeLibs(),
  33. ]
  34. def __cmp__(self, other):
  35. return cmp(self.name, other.name)
  36. class HLICOM(browser.HLIPythonObject):
  37. def GetText(self):
  38. return self.name
  39. def CalculateIsExpandable(self):
  40. return 1
  41. class HLICLSID(HLICOM):
  42. def __init__(self, myobject, name=None):
  43. if type(myobject) == type(""):
  44. myobject = pythoncom.MakeIID(myobject)
  45. if name is None:
  46. try:
  47. name = pythoncom.ProgIDFromCLSID(myobject)
  48. except pythoncom.com_error:
  49. name = str(myobject)
  50. name = "IID: " + name
  51. HLICOM.__init__(self, myobject, name)
  52. def CalculateIsExpandable(self):
  53. return 0
  54. def GetSubList(self):
  55. return []
  56. class HLI_Interface(HLICOM):
  57. pass
  58. class HLI_Enum(HLI_Interface):
  59. def GetBitmapColumn(self):
  60. return 0 # Always a folder.
  61. def CalculateIsExpandable(self):
  62. if self.myobject is not None:
  63. rc = len(self.myobject.Next(1)) > 0
  64. self.myobject.Reset()
  65. else:
  66. rc = 0
  67. return rc
  68. pass
  69. class HLI_IEnumMoniker(HLI_Enum):
  70. def GetSubList(self):
  71. ctx = pythoncom.CreateBindCtx()
  72. ret = []
  73. for mon in util.Enumerator(self.myobject):
  74. ret.append(HLI_IMoniker(mon, mon.GetDisplayName(ctx, None)))
  75. return ret
  76. class HLI_IMoniker(HLI_Interface):
  77. def GetSubList(self):
  78. ret = []
  79. ret.append(browser.MakeHLI(self.myobject.Hash(), "Hash Value"))
  80. subenum = self.myobject.Enum(1)
  81. ret.append(HLI_IEnumMoniker(subenum, "Sub Monikers"))
  82. return ret
  83. class HLIHeadingCategory(HLICOM):
  84. "A tree heading for registered categories"
  85. def GetText(self):
  86. return "Registered Categories"
  87. def GetSubList(self):
  88. catinf = pythoncom.CoCreateInstance(
  89. pythoncom.CLSID_StdComponentCategoriesMgr,
  90. None,
  91. pythoncom.CLSCTX_INPROC,
  92. pythoncom.IID_ICatInformation,
  93. )
  94. enum = util.Enumerator(catinf.EnumCategories())
  95. ret = []
  96. try:
  97. for catid, lcid, desc in enum:
  98. ret.append(HLICategory((catid, lcid, desc)))
  99. except pythoncom.com_error:
  100. # Registered categories occasionally seem to give spurious errors.
  101. pass # Use what we already have.
  102. return ret
  103. class HLICategory(HLICOM):
  104. "An actual Registered Category"
  105. def GetText(self):
  106. desc = self.myobject[2]
  107. if not desc:
  108. desc = "(unnamed category)"
  109. return desc
  110. def GetSubList(self):
  111. win32ui.DoWaitCursor(1)
  112. catid, lcid, desc = self.myobject
  113. catinf = pythoncom.CoCreateInstance(
  114. pythoncom.CLSID_StdComponentCategoriesMgr,
  115. None,
  116. pythoncom.CLSCTX_INPROC,
  117. pythoncom.IID_ICatInformation,
  118. )
  119. ret = []
  120. for clsid in util.Enumerator(catinf.EnumClassesOfCategories((catid,), ())):
  121. ret.append(HLICLSID(clsid))
  122. win32ui.DoWaitCursor(0)
  123. return ret
  124. class HLIHelpFile(HLICOM):
  125. def CalculateIsExpandable(self):
  126. return 0
  127. def GetText(self):
  128. import os
  129. fname, ctx = self.myobject
  130. base = os.path.split(fname)[1]
  131. return "Help reference in %s" % (base)
  132. def TakeDefaultAction(self):
  133. fname, ctx = self.myobject
  134. if ctx:
  135. cmd = win32con.HELP_CONTEXT
  136. else:
  137. cmd = win32con.HELP_FINDER
  138. win32api.WinHelp(win32ui.GetMainFrame().GetSafeHwnd(), fname, cmd, ctx)
  139. def GetBitmapColumn(self):
  140. return 6
  141. class HLIRegisteredTypeLibrary(HLICOM):
  142. def GetSubList(self):
  143. import os
  144. clsidstr, versionStr = self.myobject
  145. collected = []
  146. helpPath = ""
  147. key = win32api.RegOpenKey(
  148. win32con.HKEY_CLASSES_ROOT, "TypeLib\\%s\\%s" % (clsidstr, versionStr)
  149. )
  150. win32ui.DoWaitCursor(1)
  151. try:
  152. num = 0
  153. while 1:
  154. try:
  155. subKey = win32api.RegEnumKey(key, num)
  156. except win32api.error:
  157. break
  158. hSubKey = win32api.RegOpenKey(key, subKey)
  159. try:
  160. value, typ = win32api.RegQueryValueEx(hSubKey, None)
  161. if typ == win32con.REG_EXPAND_SZ:
  162. value = win32api.ExpandEnvironmentStrings(value)
  163. except win32api.error:
  164. value = ""
  165. if subKey == "HELPDIR":
  166. helpPath = value
  167. elif subKey == "Flags":
  168. flags = value
  169. else:
  170. try:
  171. lcid = int(subKey)
  172. lcidkey = win32api.RegOpenKey(key, subKey)
  173. # Enumerate the platforms
  174. lcidnum = 0
  175. while 1:
  176. try:
  177. platform = win32api.RegEnumKey(lcidkey, lcidnum)
  178. except win32api.error:
  179. break
  180. try:
  181. hplatform = win32api.RegOpenKey(lcidkey, platform)
  182. fname, typ = win32api.RegQueryValueEx(hplatform, None)
  183. if typ == win32con.REG_EXPAND_SZ:
  184. fname = win32api.ExpandEnvironmentStrings(fname)
  185. except win32api.error:
  186. fname = ""
  187. collected.append((lcid, platform, fname))
  188. lcidnum = lcidnum + 1
  189. win32api.RegCloseKey(lcidkey)
  190. except ValueError:
  191. pass
  192. num = num + 1
  193. finally:
  194. win32ui.DoWaitCursor(0)
  195. win32api.RegCloseKey(key)
  196. # Now, loop over my collected objects, adding a TypeLib and a HelpFile
  197. ret = []
  198. # if helpPath: ret.append(browser.MakeHLI(helpPath, "Help Path"))
  199. ret.append(HLICLSID(clsidstr))
  200. for lcid, platform, fname in collected:
  201. extraDescs = []
  202. if platform != "win32":
  203. extraDescs.append(platform)
  204. if lcid:
  205. extraDescs.append("locale=%s" % lcid)
  206. extraDesc = ""
  207. if extraDescs:
  208. extraDesc = " (%s)" % ", ".join(extraDescs)
  209. ret.append(HLITypeLib(fname, "Type Library" + extraDesc))
  210. ret.sort()
  211. return ret
  212. class HLITypeLibEntry(HLICOM):
  213. def GetText(self):
  214. tlb, index = self.myobject
  215. name, doc, ctx, helpFile = tlb.GetDocumentation(index)
  216. try:
  217. typedesc = HLITypeKinds[tlb.GetTypeInfoType(index)][1]
  218. except KeyError:
  219. typedesc = "Unknown!"
  220. return name + " - " + typedesc
  221. def GetSubList(self):
  222. tlb, index = self.myobject
  223. name, doc, ctx, helpFile = tlb.GetDocumentation(index)
  224. ret = []
  225. if doc:
  226. ret.append(browser.HLIDocString(doc, "Doc"))
  227. if helpFile:
  228. ret.append(HLIHelpFile((helpFile, ctx)))
  229. return ret
  230. class HLICoClass(HLITypeLibEntry):
  231. def GetSubList(self):
  232. ret = HLITypeLibEntry.GetSubList(self)
  233. tlb, index = self.myobject
  234. typeinfo = tlb.GetTypeInfo(index)
  235. attr = typeinfo.GetTypeAttr()
  236. for j in range(attr[8]):
  237. flags = typeinfo.GetImplTypeFlags(j)
  238. refType = typeinfo.GetRefTypeInfo(typeinfo.GetRefTypeOfImplType(j))
  239. refAttr = refType.GetTypeAttr()
  240. ret.append(
  241. browser.MakeHLI(refAttr[0], "Name=%s, Flags = %d" % (refAttr[0], flags))
  242. )
  243. return ret
  244. class HLITypeLibMethod(HLITypeLibEntry):
  245. def __init__(self, ob, name=None):
  246. self.entry_type = "Method"
  247. HLITypeLibEntry.__init__(self, ob, name)
  248. def GetSubList(self):
  249. ret = HLITypeLibEntry.GetSubList(self)
  250. tlb, index = self.myobject
  251. typeinfo = tlb.GetTypeInfo(index)
  252. attr = typeinfo.GetTypeAttr()
  253. for i in range(attr[7]):
  254. ret.append(HLITypeLibProperty((typeinfo, i)))
  255. for i in range(attr[6]):
  256. ret.append(HLITypeLibFunction((typeinfo, i)))
  257. return ret
  258. class HLITypeLibEnum(HLITypeLibEntry):
  259. def __init__(self, myitem):
  260. typelib, index = myitem
  261. typeinfo = typelib.GetTypeInfo(index)
  262. self.id = typeinfo.GetVarDesc(index)[0]
  263. name = typeinfo.GetNames(self.id)[0]
  264. HLITypeLibEntry.__init__(self, myitem, name)
  265. def GetText(self):
  266. return self.name + " - Enum/Module"
  267. def GetSubList(self):
  268. ret = []
  269. typelib, index = self.myobject
  270. typeinfo = typelib.GetTypeInfo(index)
  271. attr = typeinfo.GetTypeAttr()
  272. for j in range(attr[7]):
  273. vdesc = typeinfo.GetVarDesc(j)
  274. name = typeinfo.GetNames(vdesc[0])[0]
  275. ret.append(browser.MakeHLI(vdesc[1], name))
  276. return ret
  277. class HLITypeLibProperty(HLICOM):
  278. def __init__(self, myitem):
  279. typeinfo, index = myitem
  280. self.id = typeinfo.GetVarDesc(index)[0]
  281. name = typeinfo.GetNames(self.id)[0]
  282. HLICOM.__init__(self, myitem, name)
  283. def GetText(self):
  284. return self.name + " - Property"
  285. def GetSubList(self):
  286. ret = []
  287. typeinfo, index = self.myobject
  288. names = typeinfo.GetNames(self.id)
  289. if len(names) > 1:
  290. ret.append(browser.MakeHLI(names[1:], "Named Params"))
  291. vd = typeinfo.GetVarDesc(index)
  292. ret.append(browser.MakeHLI(self.id, "Dispatch ID"))
  293. ret.append(browser.MakeHLI(vd[1], "Value"))
  294. ret.append(browser.MakeHLI(vd[2], "Elem Desc"))
  295. ret.append(browser.MakeHLI(vd[3], "Var Flags"))
  296. ret.append(browser.MakeHLI(vd[4], "Var Kind"))
  297. return ret
  298. class HLITypeLibFunction(HLICOM):
  299. funckinds = {
  300. pythoncom.FUNC_VIRTUAL: "Virtual",
  301. pythoncom.FUNC_PUREVIRTUAL: "Pure Virtual",
  302. pythoncom.FUNC_STATIC: "Static",
  303. pythoncom.FUNC_DISPATCH: "Dispatch",
  304. }
  305. invokekinds = {
  306. pythoncom.INVOKE_FUNC: "Function",
  307. pythoncom.INVOKE_PROPERTYGET: "Property Get",
  308. pythoncom.INVOKE_PROPERTYPUT: "Property Put",
  309. pythoncom.INVOKE_PROPERTYPUTREF: "Property Put by reference",
  310. }
  311. funcflags = [
  312. (pythoncom.FUNCFLAG_FRESTRICTED, "Restricted"),
  313. (pythoncom.FUNCFLAG_FSOURCE, "Source"),
  314. (pythoncom.FUNCFLAG_FBINDABLE, "Bindable"),
  315. (pythoncom.FUNCFLAG_FREQUESTEDIT, "Request Edit"),
  316. (pythoncom.FUNCFLAG_FDISPLAYBIND, "Display Bind"),
  317. (pythoncom.FUNCFLAG_FDEFAULTBIND, "Default Bind"),
  318. (pythoncom.FUNCFLAG_FHIDDEN, "Hidden"),
  319. (pythoncom.FUNCFLAG_FUSESGETLASTERROR, "Uses GetLastError"),
  320. ]
  321. vartypes = {
  322. pythoncom.VT_EMPTY: "Empty",
  323. pythoncom.VT_NULL: "NULL",
  324. pythoncom.VT_I2: "Integer 2",
  325. pythoncom.VT_I4: "Integer 4",
  326. pythoncom.VT_R4: "Real 4",
  327. pythoncom.VT_R8: "Real 8",
  328. pythoncom.VT_CY: "CY",
  329. pythoncom.VT_DATE: "Date",
  330. pythoncom.VT_BSTR: "String",
  331. pythoncom.VT_DISPATCH: "IDispatch",
  332. pythoncom.VT_ERROR: "Error",
  333. pythoncom.VT_BOOL: "BOOL",
  334. pythoncom.VT_VARIANT: "Variant",
  335. pythoncom.VT_UNKNOWN: "IUnknown",
  336. pythoncom.VT_DECIMAL: "Decimal",
  337. pythoncom.VT_I1: "Integer 1",
  338. pythoncom.VT_UI1: "Unsigned integer 1",
  339. pythoncom.VT_UI2: "Unsigned integer 2",
  340. pythoncom.VT_UI4: "Unsigned integer 4",
  341. pythoncom.VT_I8: "Integer 8",
  342. pythoncom.VT_UI8: "Unsigned integer 8",
  343. pythoncom.VT_INT: "Integer",
  344. pythoncom.VT_UINT: "Unsigned integer",
  345. pythoncom.VT_VOID: "Void",
  346. pythoncom.VT_HRESULT: "HRESULT",
  347. pythoncom.VT_PTR: "Pointer",
  348. pythoncom.VT_SAFEARRAY: "SafeArray",
  349. pythoncom.VT_CARRAY: "C Array",
  350. pythoncom.VT_USERDEFINED: "User Defined",
  351. pythoncom.VT_LPSTR: "Pointer to string",
  352. pythoncom.VT_LPWSTR: "Pointer to Wide String",
  353. pythoncom.VT_FILETIME: "File time",
  354. pythoncom.VT_BLOB: "Blob",
  355. pythoncom.VT_STREAM: "IStream",
  356. pythoncom.VT_STORAGE: "IStorage",
  357. pythoncom.VT_STORED_OBJECT: "Stored object",
  358. pythoncom.VT_STREAMED_OBJECT: "Streamed object",
  359. pythoncom.VT_BLOB_OBJECT: "Blob object",
  360. pythoncom.VT_CF: "CF",
  361. pythoncom.VT_CLSID: "CLSID",
  362. }
  363. type_flags = [
  364. (pythoncom.VT_VECTOR, "Vector"),
  365. (pythoncom.VT_ARRAY, "Array"),
  366. (pythoncom.VT_BYREF, "ByRef"),
  367. (pythoncom.VT_RESERVED, "Reserved"),
  368. ]
  369. def __init__(self, myitem):
  370. typeinfo, index = myitem
  371. self.id = typeinfo.GetFuncDesc(index)[0]
  372. name = typeinfo.GetNames(self.id)[0]
  373. HLICOM.__init__(self, myitem, name)
  374. def GetText(self):
  375. return self.name + " - Function"
  376. def MakeReturnTypeName(self, typ):
  377. justtyp = typ & pythoncom.VT_TYPEMASK
  378. try:
  379. typname = self.vartypes[justtyp]
  380. except KeyError:
  381. typname = "?Bad type?"
  382. for flag, desc in self.type_flags:
  383. if flag & typ:
  384. typname = "%s(%s)" % (desc, typname)
  385. return typname
  386. def MakeReturnType(self, returnTypeDesc):
  387. if type(returnTypeDesc) == type(()):
  388. first = returnTypeDesc[0]
  389. result = self.MakeReturnType(first)
  390. if first != pythoncom.VT_USERDEFINED:
  391. result = result + " " + self.MakeReturnType(returnTypeDesc[1])
  392. return result
  393. else:
  394. return self.MakeReturnTypeName(returnTypeDesc)
  395. def GetSubList(self):
  396. ret = []
  397. typeinfo, index = self.myobject
  398. names = typeinfo.GetNames(self.id)
  399. ret.append(browser.MakeHLI(self.id, "Dispatch ID"))
  400. if len(names) > 1:
  401. ret.append(browser.MakeHLI(", ".join(names[1:]), "Named Params"))
  402. fd = typeinfo.GetFuncDesc(index)
  403. if fd[1]:
  404. ret.append(browser.MakeHLI(fd[1], "Possible result values"))
  405. if fd[8]:
  406. typ, flags, default = fd[8]
  407. val = self.MakeReturnType(typ)
  408. if flags:
  409. val = "%s (Flags=%d, default=%s)" % (val, flags, default)
  410. ret.append(browser.MakeHLI(val, "Return Type"))
  411. for argDesc in fd[2]:
  412. typ, flags, default = argDesc
  413. val = self.MakeReturnType(typ)
  414. if flags:
  415. val = "%s (Flags=%d)" % (val, flags)
  416. if default is not None:
  417. val = "%s (Default=%s)" % (val, default)
  418. ret.append(browser.MakeHLI(val, "Argument"))
  419. try:
  420. fkind = self.funckinds[fd[3]]
  421. except KeyError:
  422. fkind = "Unknown"
  423. ret.append(browser.MakeHLI(fkind, "Function Kind"))
  424. try:
  425. ikind = self.invokekinds[fd[4]]
  426. except KeyError:
  427. ikind = "Unknown"
  428. ret.append(browser.MakeHLI(ikind, "Invoke Kind"))
  429. # 5 = call conv
  430. # 5 = offset vtbl
  431. ret.append(browser.MakeHLI(fd[6], "Number Optional Params"))
  432. flagDescs = []
  433. for flag, desc in self.funcflags:
  434. if flag & fd[9]:
  435. flagDescs.append(desc)
  436. if flagDescs:
  437. ret.append(browser.MakeHLI(", ".join(flagDescs), "Function Flags"))
  438. return ret
  439. HLITypeKinds = {
  440. pythoncom.TKIND_ENUM: (HLITypeLibEnum, "Enumeration"),
  441. pythoncom.TKIND_RECORD: (HLITypeLibEntry, "Record"),
  442. pythoncom.TKIND_MODULE: (HLITypeLibEnum, "Module"),
  443. pythoncom.TKIND_INTERFACE: (HLITypeLibMethod, "Interface"),
  444. pythoncom.TKIND_DISPATCH: (HLITypeLibMethod, "Dispatch"),
  445. pythoncom.TKIND_COCLASS: (HLICoClass, "CoClass"),
  446. pythoncom.TKIND_ALIAS: (HLITypeLibEntry, "Alias"),
  447. pythoncom.TKIND_UNION: (HLITypeLibEntry, "Union"),
  448. }
  449. class HLITypeLib(HLICOM):
  450. def GetSubList(self):
  451. ret = []
  452. ret.append(browser.MakeHLI(self.myobject, "Filename"))
  453. try:
  454. tlb = pythoncom.LoadTypeLib(self.myobject)
  455. except pythoncom.com_error:
  456. return [browser.MakeHLI("%s can not be loaded" % self.myobject)]
  457. for i in range(tlb.GetTypeInfoCount()):
  458. try:
  459. ret.append(HLITypeKinds[tlb.GetTypeInfoType(i)][0]((tlb, i)))
  460. except pythoncom.com_error:
  461. ret.append(browser.MakeHLI("The type info can not be loaded!"))
  462. ret.sort()
  463. return ret
  464. class HLIHeadingRegisterdTypeLibs(HLICOM):
  465. "A tree heading for registered type libraries"
  466. def GetText(self):
  467. return "Registered Type Libraries"
  468. def GetSubList(self):
  469. # Explicit lookup in the registry.
  470. ret = []
  471. key = win32api.RegOpenKey(win32con.HKEY_CLASSES_ROOT, "TypeLib")
  472. win32ui.DoWaitCursor(1)
  473. try:
  474. num = 0
  475. while 1:
  476. try:
  477. keyName = win32api.RegEnumKey(key, num)
  478. except win32api.error:
  479. break
  480. # Enumerate all version info
  481. subKey = win32api.RegOpenKey(key, keyName)
  482. name = None
  483. try:
  484. subNum = 0
  485. bestVersion = 0.0
  486. while 1:
  487. try:
  488. versionStr = win32api.RegEnumKey(subKey, subNum)
  489. except win32api.error:
  490. break
  491. try:
  492. versionFlt = float(versionStr)
  493. except ValueError:
  494. versionFlt = 0 # ????
  495. if versionFlt > bestVersion:
  496. bestVersion = versionFlt
  497. name = win32api.RegQueryValue(subKey, versionStr)
  498. subNum = subNum + 1
  499. finally:
  500. win32api.RegCloseKey(subKey)
  501. if name is not None:
  502. ret.append(HLIRegisteredTypeLibrary((keyName, versionStr), name))
  503. num = num + 1
  504. finally:
  505. win32api.RegCloseKey(key)
  506. win32ui.DoWaitCursor(0)
  507. ret.sort()
  508. return ret
  509. def main(modal=True, mdi=False):
  510. from pywin.tools import hierlist
  511. root = HLIRoot("COM Browser")
  512. if mdi and "pywin.framework.app" in sys.modules:
  513. # do it in a MDI window
  514. browser.MakeTemplate()
  515. browser.template.OpenObject(root)
  516. else:
  517. dlg = browser.dynamic_browser(root)
  518. if modal:
  519. dlg.DoModal()
  520. else:
  521. dlg.CreateWindow()
  522. dlg.ShowWindow()
  523. if __name__ == "__main__":
  524. main(modal=win32api.GetConsoleTitle())
  525. ni = pythoncom._GetInterfaceCount()
  526. ng = pythoncom._GetGatewayCount()
  527. if ni or ng:
  528. print("Warning - exiting with %d/%d objects alive" % (ni, ng))