def _GetServiceShortName(longName):
    # looks up a services name
    # from the display name
    # Thanks to Andy McKay for this code.
    access = win32con.KEY_READ | win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE
    hkey = win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE,
                               "SYSTEM\\CurrentControlSet\\Services", 0,
                               access)
    num = win32api.RegQueryInfoKey(hkey)[0]
    longName = longName.lower()
    # loop through number of subkeys
    for x in range(0, num):
        # find service name, open subkey
        svc = win32api.RegEnumKey(hkey, x)
        skey = win32api.RegOpenKey(hkey, svc, 0, access)
        try:
            # find display name
            thisName = str(win32api.RegQueryValueEx(skey, "DisplayName")[0])
            if thisName.lower() == longName:
                return svc
        except win32api.error:
            # in case there is no key called DisplayName
            pass
    return None
Exemplo n.º 2
0
def WriteToolMenuItems(items):
    # Items is a list of (menu, command)
    # Delete the entire registry tree.
    try:
        mainKey = win32ui.GetAppRegistryKey()
        toolKey = win32api.RegOpenKey(mainKey, "Tools Menu")
    except win32ui.error:
        toolKey = None
    if toolKey is not None:
        while 1:
            try:
                subkey = win32api.RegEnumKey(toolKey, 0)
            except win32api.error:
                break
            win32api.RegDeleteKey(toolKey, subkey)
    # Keys are now removed - write the new ones.
    # But first check if we have the defaults - and if so, dont write anything!
    if items == defaultToolMenuItems:
        return
    itemNo = 1
    for menu, cmd in items:
        win32ui.WriteProfileVal("Tools Menu\\%s" % itemNo, "", menu)
        win32ui.WriteProfileVal("Tools Menu\\%s" % itemNo, "Command", cmd)
        itemNo = itemNo + 1
def __FindSvcDeps(findName):
    if type(findName) is pywintypes.UnicodeType: findName = str(findName)
    dict = {}
    k = win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE,
                            "SYSTEM\\CurrentControlSet\\Services")
    num = 0
    while 1:
        try:
            svc = win32api.RegEnumKey(k, num)
        except win32api.error:
            break
        num = num + 1
        sk = win32api.RegOpenKey(k, svc)
        try:
            deps, typ = win32api.RegQueryValueEx(sk, "DependOnService")
        except win32api.error:
            deps = ()
        for dep in deps:
            dep = dep.lower()
            dep_on = dict.get(dep, [])
            dep_on.append(svc)
            dict[dep] = dep_on

    return __ResolveDeps(findName, dict)
Exemplo n.º 4
0
    def __init__(self):
        self.path = "WindowsRegistry"
        self.map = {}
        try:
            import win32api


##            import win32con
        except ImportError:
            pass
        else:
            HKEY_CURRENT_USER = -2147483647
            HKEY_LOCAL_MACHINE = -2147483646
            KEY_ALL_ACCESS = 983103
            KEY_READ = 131097
            subkey = r"Software\Python\PythonCore\%s\Modules" % sys.winver
            for root in (HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE):
                try:
                    #hkey = win32api.RegOpenKeyEx(root, subkey, 0, KEY_ALL_ACCESS)
                    hkey = win32api.RegOpenKeyEx(root, subkey, 0, KEY_READ)
                except:
                    pass
                else:
                    numsubkeys, numvalues, lastmodified = win32api.RegQueryInfoKey(
                        hkey)
                    for i in range(numsubkeys):
                        subkeyname = win32api.RegEnumKey(hkey, i)
                        #hskey = win32api.RegOpenKeyEx(hkey, subkeyname, 0, KEY_ALL_ACCESS)
                        hskey = win32api.RegOpenKeyEx(hkey, subkeyname, 0,
                                                      KEY_READ)
                        val = win32api.RegQueryValueEx(hskey, '')
                        desc = getDescr(val[0])
                        self.map[subkeyname] = (val[0], desc)
                        hskey.Close()
                    hkey.Close()
                    break
Exemplo n.º 5
0
    def get_logins_info(self):
        accessRead = win32con.KEY_READ | win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE
        try:
            key = win32api.RegOpenKey(
                win32con.HKEY_CURRENT_USER,
                'Software\Martin Prikryl\WinSCP 2\Sessions', 0, accessRead)
        except Exception, e:
            print_debug('DEBUG', '{0}'.format(e))
            return False

        num_profiles = win32api.RegQueryInfoKey(key)[0]

        pwdFound = []
        for n in range(num_profiles):
            name_skey = win32api.RegEnumKey(key, n)

            skey = win32api.RegOpenKey(key, name_skey, 0, accessRead)
            num = win32api.RegQueryInfoKey(skey)[1]

            port = ''
            values = {}

            for nn in range(num):
                k = win32api.RegEnumValue(skey, nn)

                if k[0] == 'HostName':
                    self.set_hostname(k[1])

                if k[0] == 'UserName':
                    self.set_username(k[1])
Exemplo n.º 6
0
    ]:
        if 'delphi32.exe' in mod:
            return True
    return False


# clean up old restart records
key = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER, "Software")
key = win32api.RegOpenKey(key, "Jabber")
key = win32api.RegOpenKey(key, "Exodus")
try:
    restart = win32api.RegOpenKey(key, "Restart")

    keys = []
    for i in range(0, win32api.RegQueryInfoKey(restart)[0]):
        keys.append(win32api.RegEnumKey(restart, i))
    for subkey in keys:
        win32api.RegDeleteKey(restart, subkey)

    win32api.RegCloseKey(restart)
    win32api.RegDeleteKey(key, "Restart")
except:
    pass

count = 0
while True:
    if count > 10:
        print "Could not shut down an Exodus instance"
        sys.exit(1)
    wins = []
    last = 0
Exemplo n.º 7
0
  This is needed since you can't blast a key when subkeys exist.
  """
  try:
    h = win32api.RegOpenKey(base, path)
  except win32api.error, (code, fn, msg):
    if code != winerror.ERROR_FILE_NOT_FOUND:
      raise win32api.error(code, fn, msg)
  else:
    # parent key found and opened successfully. do some work, making sure
    # to always close the thing (error or no).
    try:
      # remove all of the subkeys
      while 1:
        try:
          subkeyname = win32api.RegEnumKey(h, 0)
        except win32api.error, (code, fn, msg):
          if code != winerror.ERROR_NO_MORE_ITEMS:
            raise win32api.error(code, fn, msg)
          break
        recurse_delete_key(path + '\\' + subkeyname, base)

      # remove the parent key
      _remove_key(path, base)
    finally:
      win32api.RegCloseKey(h)

def _cat_registrar():
  return pythoncom.CoCreateInstance(
    pythoncom.CLSID_StdComponentCategoriesMgr,
    None,
Exemplo n.º 8
0
import nt
import os
import win32api
import win32con

def rmkey(parent, key, level=0):
    sep = "    "*level
    try:
	handle = win32api.RegOpenKey(parent, key)
    except win32api.error, msg:
	print sep + "No key", `key`
	return
    print sep + "Removing key", key
    while 1:
	try:
	    subkey = win32api.RegEnumKey(handle, 0)
	except win32api.error, msg:
	    break
	rmkey(handle, subkey, level+1)
    win32api.RegCloseKey(handle)
    win32api.RegDeleteKey(parent, key)
    print sep + "Done with", key

roothandle = win32con.HKEY_LOCAL_MACHINE
pythonkey = "Software\\Python\\PythonCore\\" + sys.winver
rmkey(roothandle, pythonkey)
uninstallkey = \
 "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Python"+sys.winver
rmkey(roothandle, uninstallkey)

def rmtree(dir, level=0):
Exemplo n.º 9
0
def _get_registered_typelibs(match='HEC River Analysis System'):
    """
    adapted from pywin32

    # Copyright (c) 1996-2008, Greg Stein and Mark Hammond.
    """

    import win32api
    import win32con

    # Explicit lookup in the registry.
    result = []
    key = win32api.RegOpenKey(win32con.HKEY_CLASSES_ROOT, "TypeLib")
    try:
        num = 0
        while 1:
            try:
                key_name = win32api.RegEnumKey(key, num)
            except win32api.error:
                break
            # Enumerate all version info
            sub_key = win32api.RegOpenKey(key, key_name)
            name = None
            try:
                sub_num = 0
                best_version = 0.0
                while 1:
                    try:
                        version_str = win32api.RegEnumKey(sub_key, sub_num)
                    except win32api.error:
                        break
                    try:
                        version_flt = float(version_str)
                    except ValueError:
                        version_flt = 0  # ????
                    if version_flt > best_version:
                        best_version = version_flt
                        name = win32api.RegQueryValue(sub_key, version_str)
                    sub_num = sub_num + 1
            finally:
                win32api.RegCloseKey(sub_key)
            if name is not None and match in name:
                fname, lcid = _get_typelib_info(key_name, version_str)

                # Split version
                major, minor = version_str.split('.')

                result.append({'name': name,
                               'filename': fname,
                               'iid': key_name,
                               'lcid': lcid,
                               'major': int(major),
                               'minor': int(minor)})
            num = num + 1
    finally:
        win32api.RegCloseKey(key)

    #print(result)
    #result = sorted(result)

    return result
Exemplo n.º 10
0
 def GetSubList(self):
     import os
     clsidstr, versionStr = self.myobject
     collected = []
     helpPath = ""
     key = win32api.RegOpenKey(win32con.HKEY_CLASSES_ROOT,
                               "TypeLib\\%s\\%s" % (clsidstr, versionStr))
     win32ui.DoWaitCursor(1)
     try:
         num = 0
         while 1:
             try:
                 subKey = win32api.RegEnumKey(key, num)
             except win32api.error:
                 break
             hSubKey = win32api.RegOpenKey(key, subKey)
             try:
                 value, typ = win32api.RegQueryValueEx(hSubKey, None)
                 if typ == win32con.REG_EXPAND_SZ:
                     value = win32api.ExpandEnvironmentStrings(value)
             except win32api.error:
                 value = ""
             if subKey == "HELPDIR":
                 helpPath = value
             elif subKey == "Flags":
                 flags = value
             else:
                 try:
                     lcid = int(subKey)
                     lcidkey = win32api.RegOpenKey(key, subKey)
                     # Enumerate the platforms
                     lcidnum = 0
                     while 1:
                         try:
                             platform = win32api.RegEnumKey(
                                 lcidkey, lcidnum)
                         except win32api.error:
                             break
                         try:
                             hplatform = win32api.RegOpenKey(
                                 lcidkey, platform)
                             fname, typ = win32api.RegQueryValueEx(
                                 hplatform, None)
                             if typ == win32con.REG_EXPAND_SZ:
                                 fname = win32api.ExpandEnvironmentStrings(
                                     fname)
                         except win32api.error:
                             fname = ""
                         collected.append((lcid, platform, fname))
                         lcidnum = lcidnum + 1
                     win32api.RegCloseKey(lcidkey)
                 except ValueError:
                     pass
             num = num + 1
     finally:
         win32ui.DoWaitCursor(0)
         win32api.RegCloseKey(key)
     # Now, loop over my collected objects, adding a TypeLib and a HelpFile
     ret = []
     #               if helpPath: ret.append(browser.MakeHLI(helpPath, "Help Path"))
     ret.append(HLICLSID(clsidstr))
     for lcid, platform, fname in collected:
         extraDescs = []
         if platform != "win32":
             extraDescs.append(platform)
         if lcid:
             extraDescs.append("locale=%s" % lcid)
         extraDesc = ""
         if extraDescs: extraDesc = " (%s)" % ", ".join(extraDescs)
         ret.append(HLITypeLib(fname, "Type Library" + extraDesc))
     ret.sort()
     return ret
Exemplo n.º 11
0
def EnumTypeLib():
    ret = []
    libKeys = []
    key = win32api.RegOpenKey(win32con.HKEY_CLASSES_ROOT, "TypeLib")
    try:
        num = 0
        while 1:
            try:
                keyName = win32api.RegEnumKey(key, num)
                #print keyName
            except win32api.error:
                break
            # Enumerate all version info
            subKey = win32api.RegOpenKey(key, keyName)
            name = None
            try:
                subNum = 0
                bestVersion = 0.0
                while 1:
                    try:
                        versionStr = win32api.RegEnumKey(subKey, subNum)
                    except win32api.error:
                        break
                    try:
                        versionFlt = float(versionStr)
                    except ValueError:
                        versionFlt = 0 # ????
                    if versionFlt > bestVersion:
                        bestVersion = versionFlt
                        name = win32api.RegQueryValue(subKey, versionStr)
                    subNum = subNum + 1
            finally:
                win32api.RegCloseKey(subKey)
            if name is not None:
                libKeys.append((keyName, versionStr))
                #print name
            num += 1
    except:
        pass

    for keyName, versionStr in libKeys:
        key = win32api.RegOpenKey(win32con.HKEY_CLASSES_ROOT, "TypeLib\\%s\\%s" % (keyName, versionStr))
        num = 0
        while True:
            try:
                subKey = win32api.RegEnumKey(key, num)

                #print subKey
            except:
                break
            hSubKey = win32api.RegOpenKey(key, subKey)
            try:
                value, typ = win32api.RegQueryValueEx(hSubKey, None)
                if typ == win32con.REG_EXPAND_SZ:
                    value = win32api.ExpandEnvironmentStrings(value)
            except:
                value = ""
            if subKey=="HELPDIR":
                helpPath = value
            elif subKey.lower()=="flags":
                flags = value
            else:
                try:
                    lcid = int(subKey)
                    #print key
                    #print key, subKey
                    lcidkey = win32api.RegOpenKey(key, subKey)
                    #print lcidkey
                    # Enumerate the platforms
                    lcidnum = 0
                    while 1:
                        try:
                            platform = win32api.RegEnumKey(lcidkey, lcidnum)
                            #print platform
                        except Exception, e:
                            #print 111,e
                            break
                        try:
                            hplatform = win32api.RegOpenKey(lcidkey, platform)
                            fname, typ = win32api.RegQueryValueEx(hplatform, None)
                            if fname != None:
                                ret.append((fname, keyName))
                                #print key2
                            #print fname
                            #print lcid, platform, fname

                            #if typ == win32con.REG_EXPAND_SZ:
                                #fname = win32api.ExpandEnvironmentStrings(fname)
                                #print fname
                        except win32api.error:
                            fname = ""
                        #collected.append((lcid, platform, fname))
                        lcidnum = lcidnum + 1
                    win32api.RegCloseKey(lcidkey)
                except ValueError,e:
                    #print e
                    pass
            num += 1
Exemplo n.º 12
0
print(api.GetFullPathName('.'))
print(api.GetLocalTime())
print(api.GetLogicalDriveStrings().replace('\x00', ' '))
print(api.GetLogicalDrives())
print(api.GetLongPathName('C:'))
print(api.GetModuleFileName(0))
print(api.GetNativeSystemInfo())
print(hex(api.GetSysColor(con.COLOR_WINDOW)))
print(api.GetSystemDirectory())
print(api.GetSystemInfo())
print(api.GetSystemMetrics(con.SM_CXSCREEN))
print(api.GetSystemTime())
print(api.GetTickCount())
# print(api.GetTimeZoneInformation())
print(api.GetUserDefaultLangID())
print(api.GetUserName())
print(api.GetVersion())
print(api.GetVolumeInformation('C:'))
print(api.GetWindowsDirectory())
print(api.GlobalMemoryStatus())
print(api.MessageBeep())
print(api.MessageBox(0, 'hello', 'world', con.MB_OK))
size = api.RegQueryInfoKey(con.HKEY_LOCAL_MACHINE)
print(size)
for i in range(size[0]):
    print(api.RegEnumKey(con.HKEY_LOCAL_MACHINE, i))
try:
    print(api.SearchPath('.', 'win32con.txt'))
except:
    print('error')
print(api.WinExec('Notepad'))
Exemplo n.º 13
0
from lib_common import pc

import win32con
import win32api

import lib_com_type_lib

cgiEnv = lib_common.ScriptEnvironment("Registered COM type libraries")

grph = cgiEnv.GetGraph()

try:
    num = 0
    while 1:
        try:
            keyName = win32api.RegEnumKey(lib_com_type_lib.key, num)
        except win32api.error:
            break

        versions = lib_com_type_lib.ComKeyAllNameVersion(
            lib_com_type_lib.key, keyName)

        # sys.stderr.write("key=%s\n" % keyName)

        # Name of the last version.
        (bestTypLibName,
         bestVersion) = lib_com_type_lib.ComKeyLastName(versions)
        # sys.stderr.write("BestName=%s\n" % bestTypLibName )

        # for vers, name in list( versions.items() ):
        # 	sys.stderr.write("    vers=%s name=%s\n" % (vers,name) )
Exemplo n.º 14
0
			(string, object, type) = win32api.RegEnumValue(hkey_src, index)
#			print "CopyValue",string
			win32api.RegSetValueEx(hkey_dst, string, 0, type, object)
		except Exception, err:
			if err[0] == 259:   #No more data available
				break
			if err[0] == 5:     #Access denied
				Logger.debug("Unable to copy value: Access denied")
			else:
				Logger.exception("Unable to copy value")
		index+= 1
	
	index = 0
	while True:
		try:
			buf = win32api.RegEnumKey(hkey_src, index)
			
			buf_is_blacklisted = False
			context_blacklist = []
			for b_item in blacklist:
				parts = b_item.split("\\", 1)
				if parts[0] != buf:
					continue
				
				if len(parts) == 1 or len(parts[1]) == 0:
					buf_is_blacklisted = True
					#print "blacklisted",buf
					break
				else:
					context_blacklist.append(parts[1])
			
Exemplo n.º 15
0
    # Get the last write for the key, error if not possible

    try:
        access = win32con.KEY_READ | win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE
        hkey = win32api.RegOpenKey(key, path, 0, access)
        num = win32api.RegQueryInfoKeyW(hkey)

    except Exception, e:
        print "could not open Key", hive + "\\" + path, e[2]
        sys.exit(1)

    if recur:
        for n in xrange(num["SubKeys"]):
            try:
                eKey = win32api.RegEnumKey(hkey, n)
                hKey = win32api.RegOpenKey(key, path + "\\" + eKey, 0, access)
                mod_time = win32api.RegQueryInfoKeyW(hKey)["LastWriteTime"]
                print '"' + hive + "\\" + path + "\\" + eKey + '",', '"' + str(
                    mod_time) + '"'
            except:
                print '"' + hive + "\\" + path + "\\" + eKey + '",', "\"Access Denied\""

    else:
        print '"' + hive + "\\" + path + '",', '"' + str(
            num["LastWriteTime"]) + '"'


def usage():
    """
    Function for presenting usage of the tool.
Exemplo n.º 16
0
def list_keys(hive, key=None, use_32bit_registry=False):
    """
    Enumerates the subkeys in a registry key or hive.

    Args:

       hive (str):
            The name of the hive. Can be one of the following:

                - HKEY_LOCAL_MACHINE or HKLM
                - HKEY_CURRENT_USER or HKCU
                - HKEY_USERS or HKU
                - HKEY_CLASSES_ROOT or HKCR
                - HKEY_CURRENT_CONFIG or HKCC

        key (str):
            The key (looks like a path) to the value name. If a key is not
            passed, the keys under the hive will be returned.

        use_32bit_registry (bool):
            Accesses the 32bit portion of the registry on 64 bit installations.
            On 32bit machines this is ignored.

    Returns:
        list: A list of keys/subkeys under the hive or key.

    Usage:

        .. code-block:: python

            import salt.utils.win_reg
            winreg.list_keys(hive='HKLM', key='SOFTWARE\\Microsoft')
    """

    local_hive = _to_unicode(hive)
    local_key = _to_unicode(key)

    registry = Registry()
    try:
        hkey = registry.hkeys[local_hive]
    except KeyError:
        raise CommandExecutionError("Invalid Hive: {}".format(local_hive))
    access_mask = registry.registry_32[use_32bit_registry]

    subkeys = []
    handle = None
    try:
        handle = win32api.RegOpenKeyEx(hkey, local_key, 0, access_mask)

        for i in range(win32api.RegQueryInfoKey(handle)[0]):
            subkey = win32api.RegEnumKey(handle, i)
            if PY2:
                subkeys.append(_to_mbcs(subkey))
            else:
                subkeys.append(subkey)

    except win32api.error as exc:
        if exc.winerror == 2:
            log.debug(r"Cannot find key: %s\%s", hive, key, exc_info=True)
            return False, r"Cannot find key: {}\{}".format(hive, key)
        raise

    finally:
        if handle:
            handle.Close()

    return subkeys
Exemplo n.º 17
0
for versionStr, name in list(versions.items()):
    versionStr = "1.0"
    sys.stderr.write("vers=%s name=%s\n" % (versionStr, name))

    collected = []
    helpPath = ""
    completeVers = "TypeLib\%s\%s" % (clsidstr, versionStr)
    sys.stderr.write("completeVers=%s\n" % (completeVers))
    key = win32api.RegOpenKey(win32con.HKEY_CLASSES_ROOT, completeVers)

    try:
        num = 0
        while 1:
            try:
                subKey = win32api.RegEnumKey(key, num)
            except win32api.error:
                break
            hSubKey = win32api.RegOpenKey(key, subKey)
            try:
                value, typ = win32api.RegQueryValueEx(hSubKey, None)
                if typ == win32con.REG_EXPAND_SZ:
                    value = win32api.ExpandEnvironmentStrings(value)
            except win32api.error:
                value = ""
            if subKey == "HELPDIR":
                helpPath = value
            elif subKey == "Flags":
                flags = value
            else:
                try:
Exemplo n.º 18
0
    at the moment to upload to Google Photos with
    unlimited storage.
"""

monitor_dir = r'path:/to/recordings'

# Get the Explorer overlay ID that's used to show synced status in Google Backup and Sync.
# TODO: Save to disk or set env var instead of running every time.
reg_key = win32api.RegOpenKeyEx(
    win32con.HKEY_LOCAL_MACHINE,
    r'SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ShellIconOverlayIdentifiers',
)
i = 0
try:
    while True:
       overlay_name = win32api.RegEnumKey(reg_key, i)
       if overlay_name == 'GoogleDriveSynced':
           overlay_handler_ID = win32api.RegQueryValue(reg_key, overlay_name)
           break;
       i += 1
except win32api.error as e:
    if e.winerror == 259:
        # Couldn't find Google Backup and Drive handler, try hardcoded one anyway
        overlay_handler_ID = '{81539FE6-33C7-4CE7-90C7-1C7B8F2F2D40}'
finally:
    win32api.RegCloseKey(reg_key)

try:
    ovh = pythoncom.CoCreateInstance(overlay_handler_ID,
                                     None,
                                     pythoncom.CLSCTX_INPROC_SERVER,
Exemplo n.º 19
0
 def subkeynames(self):
     numsubkeys = win32api.RegQueryInfoKey(self.key)[0]
     return [
         win32api.RegEnumKey(self.key, index)
         for index in range(numsubkeys)
     ]
Exemplo n.º 20
0
    except win32api.error, exc:
        print "** does not exist - ", exc.strerror
    problem = CheckPathString(appPath)
    if problem:
        print problem
    else:
        if verbose: print appPath

    key = win32api.RegOpenKey(regutil.GetRootKey(),
                              regutil.BuildDefaultPythonKey() + "\\PythonPath",
                              0, win32con.KEY_READ)
    try:
        keyNo = 0
        while 1:
            try:
                appName = win32api.RegEnumKey(key, keyNo)
                appPath = win32api.RegQueryValue(key, appName)
                if verbose: print "\t" + appName + ":",
                if appPath:
                    problem = CheckPathString(appPath)
                    if problem:
                        print problem
                    else:
                        if verbose: print appPath
                else:
                    if verbose: print "(empty)"
                keyNo = keyNo + 1
            except win32api.error:
                break
    finally:
        win32api.RegCloseKey(key)
def Main():
    cgiEnv = lib_common.CgiEnv()
    clsidstr = cgiEnv.GetId()

    grph = cgiEnv.GetGraph()

    versions = lib_com_type_lib.ComKeyAllNameVersion(
        lib_com_type_lib.TypeLibRegistryKey, clsidstr)

    # typelibNode = lib_common.gUriGen.ComRegisteredTypeLibUri( clsidstr )

    ###################  See Win32_ComClass !!!!

    for versionStr, name in list(versions.items()):
        sys.stderr.write("Vers=%s Name=%s\n" % (versionStr, name))

        # TODO: The top of the tree does not make sense.

        #strVersion = "Version=%.1f" % ( versionStr )
        #nodeDllVersionNode = lib_common.gUriGen.FileUri( "DLL" + name )
        #versionNode = lib_common.gUriGen.FileUri( name )
        #grph.add( (versionNode, pc.property_information, lib_common.NodeLiteral("name="+name) ) )
        #grph.add( (versionNode, pc.property_information, lib_common.NodeLiteral(strVersion) ) )
        #grph.add( (typelibNode, pc.property_com_version, versionStr ) )

        typelibNode = lib_com_type_lib.CreateComRegisteredTypeLibNode(
            grph, clsidstr, name, versionStr)

        # collected = []
        helpPath = ""

        try:
            key = win32api.RegOpenKey(
                win32con.HKEY_CLASSES_ROOT,
                "TypeLib\\%s\\%s" % (clsidstr, versionStr))
        except Exception:
            exc = sys.exc_info()[1]
            lib_common.ErrorMessageHtml("win32api.RegOpenKey clsidstr=" +
                                        str(clsidstr) + " versionStr=" +
                                        str(versionStr) + ". Caught:" +
                                        str(exc))

        try:
            num = 0
            while True:
                try:
                    subKey = win32api.RegEnumKey(key, num)
                except win32api.error:
                    break
                hSubKey = win32api.RegOpenKey(key, subKey)
                try:
                    value, typ = win32api.RegQueryValueEx(hSubKey, None)
                    if typ == win32con.REG_EXPAND_SZ:
                        value = win32api.ExpandEnvironmentStrings(value)
                except win32api.error:
                    value = ""
                if subKey == "HELPDIR":
                    helpPath = value
                elif subKey == "Flags":
                    flags = value
                else:
                    try:
                        # lcid = localeid
                        lcid = int(subKey)
                        lcidkey = win32api.RegOpenKey(key, subKey)
                        # Enumerate the platforms
                        lcidnum = 0
                        while 1:
                            try:
                                platform = win32api.RegEnumKey(
                                    lcidkey, lcidnum)
                            except win32api.error:
                                break
                            try:
                                hplatform = win32api.RegOpenKey(
                                    lcidkey, platform)
                                fname, typ = win32api.RegQueryValueEx(
                                    hplatform, None)
                                if typ == win32con.REG_EXPAND_SZ:
                                    fname = win32api.ExpandEnvironmentStrings(
                                        fname)
                            except win32api.error:
                                fname = ""

                            # Ligne 189
                            # collected.append((lcid, platform, fname))
                            # ret.append(HLITypeLib(fname, "Type Library" + extraDesc))

                            fnameMysteryNode = lib_common.gUriGen.ComTypeLibUri(
                                fname)
                            grph.add(
                                (fnameMysteryNode, pc.property_information,
                                 lib_common.NodeLiteral("lcid=%d" % lcid)))
                            grph.add(
                                (fnameMysteryNode, pc.property_information,
                                 lib_common.NodeLiteral("platform=" +
                                                        platform)))
                            grph.add((typelibNode, pc.property_com_version,
                                      fnameMysteryNode))

                            lcidnum = lcidnum + 1
                        win32api.RegCloseKey(lcidkey)
                    except ValueError:
                        pass
                num = num + 1
        finally:
            win32api.RegCloseKey(key)

    cgiEnv.OutCgiRdf()