home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_2639 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  21.8 KB  |  672 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import win32con
  5. import win32api
  6. import win32ui
  7. import string
  8. import sys
  9. import pythoncom
  10. from win32com.client import util
  11. from pywin.tools import browser
  12.  
  13. class HLIRoot(browser.HLIPythonObject):
  14.     
  15.     def __init__(self, title):
  16.         self.name = title
  17.  
  18.     
  19.     def GetSubList(self):
  20.         return [
  21.             HLIHeadingCategory(),
  22.             HLI_IEnumMoniker(pythoncom.GetRunningObjectTable().EnumRunning(), 'Running Objects'),
  23.             HLIHeadingRegisterdTypeLibs()]
  24.  
  25.     
  26.     def __cmp__(self, other):
  27.         return cmp(self.name, other.name)
  28.  
  29.  
  30.  
  31. class HLICOM(browser.HLIPythonObject):
  32.     
  33.     def GetText(self):
  34.         return self.name
  35.  
  36.     
  37.     def CalculateIsExpandable(self):
  38.         return 1
  39.  
  40.  
  41.  
  42. class HLICLSID(HLICOM):
  43.     
  44.     def __init__(self, myobject, name = None):
  45.         if type(myobject) == type(''):
  46.             myobject = pythoncom.MakeIID(myobject)
  47.         
  48.         if name is None:
  49.             
  50.             try:
  51.                 name = pythoncom.ProgIDFromCLSID(myobject).encode('mbcs')
  52.             except pythoncom.com_error:
  53.                 name = str(myobject)
  54.  
  55.             name = 'IID: ' + name
  56.         
  57.         HLICOM.__init__(self, myobject, name)
  58.  
  59.     
  60.     def CalculateIsExpandable(self):
  61.         return 0
  62.  
  63.     
  64.     def GetSubList(self):
  65.         return []
  66.  
  67.  
  68.  
  69. class HLI_Interface(HLICOM):
  70.     pass
  71.  
  72.  
  73. class HLI_Enum(HLI_Interface):
  74.     
  75.     def GetBitmapColumn(self):
  76.         return 0
  77.  
  78.     
  79.     def CalculateIsExpandable(self):
  80.         if self.myobject is not None:
  81.             rc = len(self.myobject.Next(1)) > 0
  82.             self.myobject.Reset()
  83.         else:
  84.             rc = 0
  85.         return rc
  86.  
  87.  
  88.  
  89. class HLI_IEnumMoniker(HLI_Enum):
  90.     
  91.     def GetSubList(self):
  92.         ctx = pythoncom.CreateBindCtx()
  93.         ret = []
  94.         for mon in util.Enumerator(self.myobject):
  95.             ret.append(HLI_IMoniker(mon, mon.GetDisplayName(ctx, None)))
  96.         
  97.         return ret
  98.  
  99.  
  100.  
  101. class HLI_IMoniker(HLI_Interface):
  102.     
  103.     def GetSubList(self):
  104.         ret = []
  105.         ret.append(browser.MakeHLI(self.myobject.Hash(), 'Hash Value'))
  106.         subenum = self.myobject.Enum(1)
  107.         ret.append(HLI_IEnumMoniker(subenum, 'Sub Monikers'))
  108.         return ret
  109.  
  110.  
  111.  
  112. class HLIHeadingCategory(HLICOM):
  113.     
  114.     def GetText(self):
  115.         return 'Registered Categories'
  116.  
  117.     
  118.     def GetSubList(self):
  119.         catinf = pythoncom.CoCreateInstance(pythoncom.CLSID_StdComponentCategoriesMgr, None, pythoncom.CLSCTX_INPROC, pythoncom.IID_ICatInformation)
  120.         enum = util.Enumerator(catinf.EnumCategories())
  121.         ret = []
  122.         
  123.         try:
  124.             for catid, lcid, desc in enum:
  125.                 ret.append(HLICategory((catid, lcid, desc)))
  126.         except pythoncom.com_error:
  127.             pass
  128.  
  129.         return ret
  130.  
  131.  
  132.  
  133. class HLICategory(HLICOM):
  134.     
  135.     def GetText(self):
  136.         desc = self.myobject[2]
  137.         if not desc:
  138.             desc = '(unnamed category)'
  139.         
  140.         return desc
  141.  
  142.     
  143.     def GetSubList(self):
  144.         win32ui.DoWaitCursor(1)
  145.         (catid, lcid, desc) = self.myobject
  146.         catinf = pythoncom.CoCreateInstance(pythoncom.CLSID_StdComponentCategoriesMgr, None, pythoncom.CLSCTX_INPROC, pythoncom.IID_ICatInformation)
  147.         ret = []
  148.         for clsid in util.Enumerator(catinf.EnumClassesOfCategories((catid,), ())):
  149.             ret.append(HLICLSID(clsid))
  150.         
  151.         win32ui.DoWaitCursor(0)
  152.         return ret
  153.  
  154.  
  155.  
  156. class HLIHelpFile(HLICOM):
  157.     
  158.     def CalculateIsExpandable(self):
  159.         return 0
  160.  
  161.     
  162.     def GetText(self):
  163.         import os
  164.         (fname, ctx) = self.myobject
  165.         base = os.path.split(fname)[1]
  166.         return 'Help reference in %s' % base
  167.  
  168.     
  169.     def TakeDefaultAction(self):
  170.         (fname, ctx) = self.myobject
  171.         if ctx:
  172.             cmd = win32con.HELP_CONTEXT
  173.         else:
  174.             cmd = win32con.HELP_FINDER
  175.         win32api.WinHelp(win32ui.GetMainFrame().GetSafeHwnd(), fname, cmd, ctx)
  176.  
  177.     
  178.     def GetBitmapColumn(self):
  179.         return 6
  180.  
  181.  
  182.  
  183. class HLIRegisteredTypeLibrary(HLICOM):
  184.     
  185.     def GetSubList(self):
  186.         import os
  187.         (clsidstr, versionStr) = self.myobject
  188.         collected = []
  189.         helpPath = ''
  190.         key = win32api.RegOpenKey(win32con.HKEY_CLASSES_ROOT, 'TypeLib\\%s\\%s' % (clsidstr, versionStr))
  191.         win32ui.DoWaitCursor(1)
  192.         
  193.         try:
  194.             num = 0
  195.             while None:
  196.                 
  197.                 try:
  198.                     subKey = win32api.RegEnumKey(key, num)
  199.                 except win32api.error:
  200.                     break
  201.  
  202.                 hSubKey = win32api.RegOpenKey(key, subKey)
  203.                 
  204.                 try:
  205.                     (value, typ) = win32api.RegQueryValueEx(hSubKey, None)
  206.                     if typ == win32con.REG_EXPAND_SZ:
  207.                         value = win32api.ExpandEnvironmentStrings(value)
  208.                 except win32api.error:
  209.                     value = ''
  210.  
  211.                 if subKey == 'HELPDIR':
  212.                     helpPath = value
  213.                 elif subKey == 'Flags':
  214.                     flags = value
  215.                 else:
  216.                     
  217.                     try:
  218.                         lcid = string.atof(subKey)
  219.                         lcidkey = win32api.RegOpenKey(key, subKey)
  220.                         lcidnum = 0
  221.                         while None:
  222.                             
  223.                             try:
  224.                                 platform = win32api.RegEnumKey(lcidkey, lcidnum)
  225.                             except win32api.error:
  226.                                 break
  227.  
  228.                             
  229.                             try:
  230.                                 hplatform = win32api.RegOpenKey(lcidkey, platform)
  231.                                 (fname, typ) = win32api.RegQueryValueEx(hplatform, None)
  232.                                 if typ == win32con.REG_EXPAND_SZ:
  233.                                     fname = win32api.ExpandEnvironmentStrings(fname)
  234.                             except win32api.error:
  235.                                 fname = ''
  236.  
  237.                             lcidnum = lcidnum + 1
  238.                             continue
  239.                             win32api.RegCloseKey(lcidkey)
  240.                     except ValueError:
  241.                         pass
  242.                     
  243.  
  244.                 num = num + 1
  245.             win32ui.DoWaitCursor(0)
  246.             win32api.RegCloseKey(key)
  247.             ret = []
  248.             ret.append(HLICLSID(clsidstr))
  249.             for lcid, platform, fname in collected:
  250.                 extraDescs = []
  251.                 if platform != 'win32':
  252.                     extraDescs.append(platform)
  253.                 
  254.                 if lcid:
  255.                     extraDescs.append('locale=%s' % lcid)
  256.                 
  257.                 extraDesc = ''
  258.                 if extraDescs:
  259.                     extraDesc = ' (%s)' % string.join(extraDescs, ', ')
  260.                 
  261.                 ret.append(HLITypeLib(fname, 'Type Library' + extraDesc))
  262.             
  263.             ret.sort()
  264.             return ret
  265.  
  266.  
  267.  
  268.  
  269. class HLITypeLibEntry(HLICOM):
  270.     
  271.     def GetText(self):
  272.         (tlb, index) = self.myobject
  273.         (name, doc, ctx, helpFile) = tlb.GetDocumentation(index)
  274.         
  275.         try:
  276.             typedesc = HLITypeKinds[tlb.GetTypeInfoType(index)][1]
  277.         except KeyError:
  278.             typedesc = 'Unknown!'
  279.  
  280.         return name + ' - ' + typedesc
  281.  
  282.     
  283.     def GetSubList(self):
  284.         (tlb, index) = self.myobject
  285.         (name, doc, ctx, helpFile) = tlb.GetDocumentation(index)
  286.         ret = []
  287.         if doc:
  288.             ret.append(browser.HLIDocString(doc, 'Doc'))
  289.         
  290.         if helpFile:
  291.             ret.append(HLIHelpFile((helpFile, ctx)))
  292.         
  293.         return ret
  294.  
  295.  
  296.  
  297. class HLICoClass(HLITypeLibEntry):
  298.     
  299.     def GetSubList(self):
  300.         ret = HLITypeLibEntry.GetSubList(self)
  301.         (tlb, index) = self.myobject
  302.         typeinfo = tlb.GetTypeInfo(index)
  303.         attr = typeinfo.GetTypeAttr()
  304.         for j in range(attr[8]):
  305.             flags = typeinfo.GetImplTypeFlags(j)
  306.             refType = typeinfo.GetRefTypeInfo(typeinfo.GetRefTypeOfImplType(j))
  307.             refAttr = refType.GetTypeAttr()
  308.             ret.append(browser.MakeHLI(refAttr[0], 'Name=%s, Flags = %d' % (refAttr[0], flags)))
  309.         
  310.         return ret
  311.  
  312.  
  313.  
  314. class HLITypeLibMethod(HLITypeLibEntry):
  315.     
  316.     def __init__(self, ob, name = None):
  317.         self.entry_type = 'Method'
  318.         HLITypeLibEntry.__init__(self, ob, name)
  319.  
  320.     
  321.     def GetSubList(self):
  322.         ret = HLITypeLibEntry.GetSubList(self)
  323.         (tlb, index) = self.myobject
  324.         typeinfo = tlb.GetTypeInfo(index)
  325.         attr = typeinfo.GetTypeAttr()
  326.         for i in range(attr[7]):
  327.             ret.append(HLITypeLibProperty((typeinfo, i)))
  328.         
  329.         for i in range(attr[6]):
  330.             ret.append(HLITypeLibFunction((typeinfo, i)))
  331.         
  332.         return ret
  333.  
  334.  
  335.  
  336. class HLITypeLibEnum(HLITypeLibEntry):
  337.     
  338.     def __init__(self, myitem):
  339.         (typelib, index) = myitem
  340.         typeinfo = typelib.GetTypeInfo(index)
  341.         self.id = typeinfo.GetVarDesc(index)[0]
  342.         name = typeinfo.GetNames(self.id)[0].encode('mbcs')
  343.         HLITypeLibEntry.__init__(self, myitem, name)
  344.  
  345.     
  346.     def GetText(self):
  347.         return self.name + ' - Enum/Module'
  348.  
  349.     
  350.     def GetSubList(self):
  351.         ret = []
  352.         (typelib, index) = self.myobject
  353.         typeinfo = typelib.GetTypeInfo(index)
  354.         attr = typeinfo.GetTypeAttr()
  355.         for j in range(attr[7]):
  356.             vdesc = typeinfo.GetVarDesc(j)
  357.             name = typeinfo.GetNames(vdesc[0])[0].encode('mbcs')
  358.             ret.append(browser.MakeHLI(vdesc[1], name))
  359.         
  360.         return ret
  361.  
  362.  
  363.  
  364. class HLITypeLibProperty(HLICOM):
  365.     
  366.     def __init__(self, myitem):
  367.         (typeinfo, index) = myitem
  368.         self.id = typeinfo.GetVarDesc(index)[0]
  369.         name = typeinfo.GetNames(self.id)[0].encode('mbcs')
  370.         HLICOM.__init__(self, myitem, name)
  371.  
  372.     
  373.     def GetText(self):
  374.         return self.name + ' - Property'
  375.  
  376.     
  377.     def GetSubList(self):
  378.         ret = []
  379.         (typeinfo, index) = self.myobject
  380.         names = typeinfo.GetNames(self.id)
  381.         if len(names) > 1:
  382.             ret.append(browser.MakeHLI(names[1:], 'Named Params'))
  383.         
  384.         vd = typeinfo.GetVarDesc(index)
  385.         ret.append(browser.MakeHLI(self.id, 'Dispatch ID'))
  386.         ret.append(browser.MakeHLI(vd[1], 'Value'))
  387.         ret.append(browser.MakeHLI(vd[2], 'Elem Desc'))
  388.         ret.append(browser.MakeHLI(vd[3], 'Var Flags'))
  389.         ret.append(browser.MakeHLI(vd[4], 'Var Kind'))
  390.         return ret
  391.  
  392.  
  393.  
  394. class HLITypeLibFunction(HLICOM):
  395.     funckinds = {
  396.         pythoncom.FUNC_VIRTUAL: 'Virtual',
  397.         pythoncom.FUNC_PUREVIRTUAL: 'Pure Virtual',
  398.         pythoncom.FUNC_STATIC: 'Static',
  399.         pythoncom.FUNC_DISPATCH: 'Dispatch' }
  400.     invokekinds = {
  401.         pythoncom.INVOKE_FUNC: 'Function',
  402.         pythoncom.INVOKE_PROPERTYGET: 'Property Get',
  403.         pythoncom.INVOKE_PROPERTYPUT: 'Property Put',
  404.         pythoncom.INVOKE_PROPERTYPUTREF: 'Property Put by reference' }
  405.     funcflags = [
  406.         (pythoncom.FUNCFLAG_FRESTRICTED, 'Restricted'),
  407.         (pythoncom.FUNCFLAG_FSOURCE, 'Source'),
  408.         (pythoncom.FUNCFLAG_FBINDABLE, 'Bindable'),
  409.         (pythoncom.FUNCFLAG_FREQUESTEDIT, 'Request Edit'),
  410.         (pythoncom.FUNCFLAG_FDISPLAYBIND, 'Display Bind'),
  411.         (pythoncom.FUNCFLAG_FDEFAULTBIND, 'Default Bind'),
  412.         (pythoncom.FUNCFLAG_FHIDDEN, 'Hidden'),
  413.         (pythoncom.FUNCFLAG_FUSESGETLASTERROR, 'Uses GetLastError')]
  414.     vartypes = {
  415.         pythoncom.VT_EMPTY: 'Empty',
  416.         pythoncom.VT_NULL: 'NULL',
  417.         pythoncom.VT_I2: 'Integer 2',
  418.         pythoncom.VT_I4: 'Integer 4',
  419.         pythoncom.VT_R4: 'Real 4',
  420.         pythoncom.VT_R8: 'Real 8',
  421.         pythoncom.VT_CY: 'CY',
  422.         pythoncom.VT_DATE: 'Date',
  423.         pythoncom.VT_BSTR: 'String',
  424.         pythoncom.VT_DISPATCH: 'IDispatch',
  425.         pythoncom.VT_ERROR: 'Error',
  426.         pythoncom.VT_BOOL: 'BOOL',
  427.         pythoncom.VT_VARIANT: 'Variant',
  428.         pythoncom.VT_UNKNOWN: 'IUnknown',
  429.         pythoncom.VT_DECIMAL: 'Decimal',
  430.         pythoncom.VT_I1: 'Integer 1',
  431.         pythoncom.VT_UI1: 'Unsigned integer 1',
  432.         pythoncom.VT_UI2: 'Unsigned integer 2',
  433.         pythoncom.VT_UI4: 'Unsigned integer 4',
  434.         pythoncom.VT_I8: 'Integer 8',
  435.         pythoncom.VT_UI8: 'Unsigned integer 8',
  436.         pythoncom.VT_INT: 'Integer',
  437.         pythoncom.VT_UINT: 'Unsigned integer',
  438.         pythoncom.VT_VOID: 'Void',
  439.         pythoncom.VT_HRESULT: 'HRESULT',
  440.         pythoncom.VT_PTR: 'Pointer',
  441.         pythoncom.VT_SAFEARRAY: 'SafeArray',
  442.         pythoncom.VT_CARRAY: 'C Array',
  443.         pythoncom.VT_USERDEFINED: 'User Defined',
  444.         pythoncom.VT_LPSTR: 'Pointer to string',
  445.         pythoncom.VT_LPWSTR: 'Pointer to Wide String',
  446.         pythoncom.VT_FILETIME: 'File time',
  447.         pythoncom.VT_BLOB: 'Blob',
  448.         pythoncom.VT_STREAM: 'IStream',
  449.         pythoncom.VT_STORAGE: 'IStorage',
  450.         pythoncom.VT_STORED_OBJECT: 'Stored object',
  451.         pythoncom.VT_STREAMED_OBJECT: 'Streamed object',
  452.         pythoncom.VT_BLOB_OBJECT: 'Blob object',
  453.         pythoncom.VT_CF: 'CF',
  454.         pythoncom.VT_CLSID: 'CLSID' }
  455.     type_flags = [
  456.         (pythoncom.VT_VECTOR, 'Vector'),
  457.         (pythoncom.VT_ARRAY, 'Array'),
  458.         (pythoncom.VT_BYREF, 'ByRef'),
  459.         (pythoncom.VT_RESERVED, 'Reserved')]
  460.     
  461.     def __init__(self, myitem):
  462.         (typeinfo, index) = myitem
  463.         self.id = typeinfo.GetFuncDesc(index)[0]
  464.         name = typeinfo.GetNames(self.id)[0].encode('mbcs')
  465.         HLICOM.__init__(self, myitem, name)
  466.  
  467.     
  468.     def GetText(self):
  469.         return self.name + ' - Function'
  470.  
  471.     
  472.     def MakeReturnTypeName(self, typ):
  473.         justtyp = typ & pythoncom.VT_TYPEMASK
  474.         
  475.         try:
  476.             typname = self.vartypes[justtyp]
  477.         except KeyError:
  478.             typname = '?Bad type?'
  479.  
  480.         for flag, desc in self.type_flags:
  481.             if flag & typ:
  482.                 typname = '%s(%s)' % (desc, typname)
  483.                 continue
  484.         
  485.         return typname
  486.  
  487.     
  488.     def MakeReturnType(self, returnTypeDesc):
  489.         if type(returnTypeDesc) == type(()):
  490.             first = returnTypeDesc[0]
  491.             result = self.MakeReturnType(first)
  492.             if first != pythoncom.VT_USERDEFINED:
  493.                 result = result + ' ' + self.MakeReturnType(returnTypeDesc[1])
  494.             
  495.             return result
  496.         return self.MakeReturnTypeName(returnTypeDesc)
  497.  
  498.     
  499.     def GetSubList(self):
  500.         ret = []
  501.         (typeinfo, index) = self.myobject
  502.         names = typeinfo.GetNames(self.id)
  503.         ret.append(browser.MakeHLI(self.id, 'Dispatch ID'))
  504.         if len(names) > 1:
  505.             ret.append(browser.MakeHLI(', '.join(names[1:]).encode('mbcs'), 'Named Params'))
  506.         
  507.         fd = typeinfo.GetFuncDesc(index)
  508.         if fd[1]:
  509.             ret.append(browser.MakeHLI(fd[1], 'Possible result values'))
  510.         
  511.         if fd[8]:
  512.             (typ, flags, default) = fd[8]
  513.             val = self.MakeReturnType(typ)
  514.             if flags:
  515.                 val = '%s (Flags=%d, default=%s)' % (val, flags, default)
  516.             
  517.             ret.append(browser.MakeHLI(val, 'Return Type'))
  518.         
  519.         for argDesc in fd[2]:
  520.             (typ, flags, default) = argDesc
  521.             val = self.MakeReturnType(typ)
  522.             if flags:
  523.                 val = '%s (Flags=%d)' % (val, flags)
  524.             
  525.             if default is not None:
  526.                 val = '%s (Default=%s)' % (val, default)
  527.             
  528.             ret.append(browser.MakeHLI(val, 'Argument'))
  529.         
  530.         
  531.         try:
  532.             fkind = self.funckinds[fd[3]]
  533.         except KeyError:
  534.             fkind = 'Unknown'
  535.  
  536.         ret.append(browser.MakeHLI(fkind, 'Function Kind'))
  537.         
  538.         try:
  539.             ikind = self.invokekinds[fd[4]]
  540.         except KeyError:
  541.             ikind = 'Unknown'
  542.  
  543.         ret.append(browser.MakeHLI(ikind, 'Invoke Kind'))
  544.         ret.append(browser.MakeHLI(fd[6], 'Number Optional Params'))
  545.         flagDescs = []
  546.         for flag, desc in self.funcflags:
  547.             if flag & fd[9]:
  548.                 flagDescs.append(desc)
  549.                 continue
  550.         
  551.         if flagDescs:
  552.             ret.append(browser.MakeHLI(string.join(flagDescs, ', '), 'Function Flags'))
  553.         
  554.         return ret
  555.  
  556.  
  557. HLITypeKinds = {
  558.     pythoncom.TKIND_ENUM: (HLITypeLibEnum, 'Enumeration'),
  559.     pythoncom.TKIND_RECORD: (HLITypeLibEntry, 'Record'),
  560.     pythoncom.TKIND_MODULE: (HLITypeLibEnum, 'Module'),
  561.     pythoncom.TKIND_INTERFACE: (HLITypeLibMethod, 'Interface'),
  562.     pythoncom.TKIND_DISPATCH: (HLITypeLibMethod, 'Dispatch'),
  563.     pythoncom.TKIND_COCLASS: (HLICoClass, 'CoClass'),
  564.     pythoncom.TKIND_ALIAS: (HLITypeLibEntry, 'Alias'),
  565.     pythoncom.TKIND_UNION: (HLITypeLibEntry, 'Union') }
  566.  
  567. class HLITypeLib(HLICOM):
  568.     
  569.     def GetSubList(self):
  570.         ret = []
  571.         ret.append(browser.MakeHLI(self.myobject, 'Filename'))
  572.         
  573.         try:
  574.             tlb = pythoncom.LoadTypeLib(self.myobject)
  575.         except pythoncom.com_error:
  576.             return [
  577.                 browser.MakeHLI('%s can not be loaded' % self.myobject)]
  578.  
  579.         for i in range(tlb.GetTypeInfoCount()):
  580.             
  581.             try:
  582.                 ret.append(HLITypeKinds[tlb.GetTypeInfoType(i)][0]((tlb, i)))
  583.             continue
  584.             except pythoncom.com_error:
  585.                 ret.append(browser.MakeHLI('The type info can not be loaded!'))
  586.                 continue
  587.             
  588.  
  589.         
  590.         ret.sort()
  591.         return ret
  592.  
  593.  
  594.  
  595. class HLIHeadingRegisterdTypeLibs(HLICOM):
  596.     
  597.     def GetText(self):
  598.         return 'Registered Type Libraries'
  599.  
  600.     
  601.     def GetSubList(self):
  602.         ret = []
  603.         key = win32api.RegOpenKey(win32con.HKEY_CLASSES_ROOT, 'TypeLib')
  604.         win32ui.DoWaitCursor(1)
  605.         
  606.         try:
  607.             num = 0
  608.             while None:
  609.                 
  610.                 try:
  611.                     keyName = win32api.RegEnumKey(key, num)
  612.                 except win32api.error:
  613.                     break
  614.  
  615.                 subKey = win32api.RegOpenKey(key, keyName)
  616.                 name = None
  617.                 
  618.                 try:
  619.                     subNum = 0
  620.                     bestVersion = 0
  621.                     while None:
  622.                         
  623.                         try:
  624.                             versionStr = win32api.RegEnumKey(subKey, subNum)
  625.                         except win32api.error:
  626.                             break
  627.  
  628.                         
  629.                         try:
  630.                             versionFlt = string.atof(versionStr)
  631.                         except ValueError:
  632.                             versionFlt = 0
  633.  
  634.                         if versionFlt > bestVersion:
  635.                             bestVersion = versionFlt
  636.                             name = win32api.RegQueryValue(subKey, versionStr)
  637.                         
  638.                         subNum = subNum + 1
  639.                     win32api.RegCloseKey(subKey)
  640.                     if name is not None:
  641.                         ret.append(HLIRegisteredTypeLibrary((keyName, versionStr), name))
  642.                     
  643.                     num = num + 1
  644.                 finally:
  645.                     win32api.RegCloseKey(key)
  646.                     win32ui.DoWaitCursor(0)
  647.  
  648.                 return ret
  649.  
  650.  
  651.  
  652.  
  653. def main():
  654.     hierlist = hierlist
  655.     import pywin.tools
  656.     root = HLIRoot('COM Browser')
  657.     if sys.modules.has_key('app'):
  658.         browser.MakeTemplate()
  659.         browser.template.OpenObject(root)
  660.     else:
  661.         dlg = browser.dynamic_browser(root)
  662.         dlg.DoModal()
  663.  
  664. if __name__ == '__main__':
  665.     main()
  666.     ni = pythoncom._GetInterfaceCount()
  667.     ng = pythoncom._GetGatewayCount()
  668.     if ni or ng:
  669.         print 'Warning - exiting with %d/%d objects alive' % (ni, ng)
  670.     
  671.  
  672.