#!/usr/bin/python ''' author: tlviewer@yahoo.com script: EnumTL.py keywords: registry enum license typelib description: scriptlet to enum a subkey collection date: 11/8/02 3:03PM relatedDoc=EnumLic.py.html ''' import os, sys import win32api as wi import win32con as wc import string as st #exercise to enumerate a subkey collection # try this for the Licenses key, then the TypeLib key kName = "Licenses" kName = "TypeLib" # get a handle pyk = wi.RegOpenKey( wc.HKEY_CLASSES_ROOT, kName) # get key info, num1 has the key count (num1, vals, works) = wi.RegQueryInfoKey( pyk ) print num1, vals, works nt = 0 # done = 0 for nt in range(nt,num1): guid = wi.RegEnumKey( pyk, nt) svers = '' win32path = '' ''' for TypeLibs we need to step down to the version key and read the help string (default value) ''' pyj = wi.RegOpenKey( wc.HKEY_CLASSES_ROOT, os.path.join(kName, guid) ) num2 = 0 (num2, val2, work2) = wi.RegQueryInfoKey(pyj) if num2 <= 0: # jump to next in for statement print "empty guid, with no subkeys at ",guid continue # if num2 > 0: for j in range(0,num2): # we are supporting multi versions, like Ado (2.1, 2.5, 2.7, etc) svers = wi.RegEnumKey( pyj, j) # version must be a decimal value if st.find(svers, '.') < 0 : break valkey = wi.RegQueryValue( pyj, svers) pym = wi.RegOpenKey( wc.HKEY_CLASSES_ROOT, os.path.join("TypeLib", guid,svers) ) #HKEY_CLASSES_ROOT\TypeLib\{000204EF-0000-0000-C000-000000000046}\6.0\9\win32 (num3, val3, work3) = wi.RegQueryInfoKey(pym) if num3 > 0: langcode = wi.RegEnumKey( pym, 0) pyn = wi.RegOpenKey( wc.HKEY_CLASSES_ROOT, os.path.join("TypeLib", guid,svers,langcode) ) (num4, val4, work4) = wi.RegQueryInfoKey(pyn) if num4 > 0: sub1 = wi.RegEnumKey( pyn, 0) try: win32path = wi.RegQueryValue( pyn, sub1) print guid, svers, valkey, langcode, win32path except: print "bad path at ",guid # else: # valkey = wi.RegQueryValue( pyk, guid) nt = nt + 1 pyk.Close() sys.exit()