def Main():
    cgiEnv = lib_common.ScriptEnvironment()

    grph = cgiEnv.GetGraph()

    try:
        num = 0
        while True:
            try:
                # DO NOT close handle.
                # (<class 'pywintypes.error'>, error(6, 'RegQueryInfoKey', 'The handle is invalid.')
                key_name = win32api.RegEnumKey(
                    lib_com_type_lib.TypeLibRegistryKey, num)
            except win32api.error as exc:
                logging.warning("RegEnumKey CAUGHT:%s", str(exc))
                break

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

            # Name of the last version.
            best_typ_lib_name, best_version = lib_com_type_lib.ComKeyLastName(
                versions)

            # The name will be awful. First we must experiment a bit.
            lib_com_type_lib.CreateComRegisteredTypeLibNode(
                grph, key_name, best_typ_lib_name, best_version)

            num = num + 1
    finally:
        # This avoids:  error(6, 'RegQueryInfoKey', 'The handle is invalid.')
        logging.error("DO NOT close handle")
        # win32api.RegCloseKey(lib_com_type_lib.TypeLibRegistryKey

    cgiEnv.OutCgiRdf()
Example #2
0
def Main():
    cgiEnv = lib_common.CgiEnv()

    grph = cgiEnv.GetGraph()

    try:
        num = 0
        while True:
            try:
                # DO NOT close handle.
                # (<class 'pywintypes.error'>, error(6, 'RegQueryInfoKey', 'The handle is invalid.')
                keyName = win32api.RegEnumKey(
                    lib_com_type_lib.TypeLibRegistryKey, num)
            except win32api.error:
                exc = sys.exc_info()
                WARNING("RegEnumKey CAUGHT:%s", str(exc))
                break

            versions = lib_com_type_lib.ComKeyAllNameVersion(
                lib_com_type_lib.TypeLibRegistryKey, 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) )

            # The name will be awful. First we must experiment a bit.
            typelibNode = lib_com_type_lib.CreateComRegisteredTypeLibNode(
                grph, keyName, bestTypLibName, bestVersion)

            num = num + 1
    finally:
        # This avoids:  error(6, 'RegQueryInfoKey', 'The handle is invalid.')
        ERROR("DO NOT close handle")
        # win32api.RegCloseKey(lib_com_type_lib.TypeLibRegistryKey

    cgiEnv.OutCgiRdf()
Example #3
0
from lib_common import pc

import win32con
import win32api

import lib_com_type_lib

# SISMILAR TO com_registered_type_lib_versions.py. WHY ???

cgiEnv = lib_common.CgiEnv("Versions of registered COM type libraries")
clsidstr = cgiEnv.GetId()

grph = cgiEnv.GetGraph()

# key = win32api.RegOpenKey(win32con.HKEY_CLASSES_ROOT, "TypeLib")
versions = lib_com_type_lib.ComKeyAllNameVersion(lib_com_type_lib.key,
                                                 clsidstr)

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:
Example #4
0
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) )

        # The name will be awful. First we must experiment a bit.
        typelibNode = lib_common.gUriGen.ComTypeLibUri(keyName)
        strTypLibName = bestTypLibName + " / " + str(bestVersion)
        grph.add((typelibNode, pc.property_information,
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()