Python win32api.RegEnumKey() Examples

The following are 30 code examples of win32api.RegEnumKey(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module win32api , or try the search function .
Example #1
Source File: msvccompiler.py    From meddle with MIT License 7 votes vote down vote up
def read_keys(base, key):
    """Return list of registry keys."""

    try:
        handle = RegOpenKeyEx(base, key)
    except RegError:
        return None
    L = []
    i = 0
    while 1:
        try:
            k = RegEnumKey(handle, i)
        except RegError:
            break
        L.append(k)
        i = i + 1
    return L 
Example #2
Source File: msvccompiler.py    From CTFCrackTools-V2 with GNU General Public License v3.0 6 votes vote down vote up
def read_keys(base, key):
    """Return list of registry keys."""

    try:
        handle = RegOpenKeyEx(base, key)
    except RegError:
        return None
    L = []
    i = 0
    while 1:
        try:
            k = RegEnumKey(handle, i)
        except RegError:
            break
        L.append(k)
        i = i + 1
    return L 
Example #3
Source File: msvccompiler.py    From setuptools with MIT License 6 votes vote down vote up
def read_keys(base, key):
    """Return list of registry keys."""
    try:
        handle = RegOpenKeyEx(base, key)
    except RegError:
        return None
    L = []
    i = 0
    while True:
        try:
            k = RegEnumKey(handle, i)
        except RegError:
            break
        L.append(k)
        i += 1
    return L 
Example #4
Source File: msvccompiler.py    From datafari with Apache License 2.0 6 votes vote down vote up
def read_keys(base, key):
    """Return list of registry keys."""

    try:
        handle = RegOpenKeyEx(base, key)
    except RegError:
        return None
    L = []
    i = 0
    while 1:
        try:
            k = RegEnumKey(handle, i)
        except RegError:
            break
        L.append(k)
        i = i + 1
    return L 
Example #5
Source File: util.py    From peach with Mozilla Public License 2.0 6 votes vote down vote up
def deleteKey(self, hKey, subKey):
        """
        Recursively remove registry keys.
        """
        try:
            hKey = win32api.RegOpenKeyEx(hKey, subKey, 0,
                                         win32con.KEY_ALL_ACCESS)
            try:
                while True:
                    s = win32api.RegEnumKey(hKey, 0)
                    self.deleteKey(hKey, s)
                    print("CleanupRegistry: Removing sub-key '{}'".format(s))
                    win32api.RegDeleteKey(hKey, s)
            except win32api.error:
                pass
            finally:
                win32api.RegCloseKey(hKey)
        except:
            print("Warning: Unable to open registry key!")
            pass 
Example #6
Source File: msvccompiler.py    From Splunking-Crime with GNU Affero General Public License v3.0 6 votes vote down vote up
def read_keys(base, key):
    """Return list of registry keys."""

    try:
        handle = RegOpenKeyEx(base, key)
    except RegError:
        return None
    L = []
    i = 0
    while 1:
        try:
            k = RegEnumKey(handle, i)
        except RegError:
            break
        L.append(k)
        i = i + 1
    return L 
Example #7
Source File: msvccompiler.py    From PokemonGo-DesktopMap with MIT License 6 votes vote down vote up
def read_keys(base, key):
    """Return list of registry keys."""

    try:
        handle = RegOpenKeyEx(base, key)
    except RegError:
        return None
    L = []
    i = 0
    while 1:
        try:
            k = RegEnumKey(handle, i)
        except RegError:
            break
        L.append(k)
        i = i + 1
    return L 
Example #8
Source File: msvccompiler.py    From RevitBatchProcessor with GNU General Public License v3.0 6 votes vote down vote up
def read_keys(base, key):
    """Return list of registry keys."""

    try:
        handle = RegOpenKeyEx(base, key)
    except RegError:
        return None
    L = []
    i = 0
    while 1:
        try:
            k = RegEnumKey(handle, i)
        except RegError:
            break
        L.append(k)
        i = i + 1
    return L 
Example #9
Source File: msvccompiler.py    From ironpython3 with Apache License 2.0 6 votes vote down vote up
def read_keys(base, key):
    """Return list of registry keys."""
    try:
        handle = RegOpenKeyEx(base, key)
    except RegError:
        return None
    L = []
    i = 0
    while True:
        try:
            k = RegEnumKey(handle, i)
        except RegError:
            break
        L.append(k)
        i += 1
    return L 
Example #10
Source File: msvccompiler.py    From unity-python with MIT License 6 votes vote down vote up
def read_keys(base, key):
    """Return list of registry keys."""

    try:
        handle = RegOpenKeyEx(base, key)
    except RegError:
        return None
    L = []
    i = 0
    while 1:
        try:
            k = RegEnumKey(handle, i)
        except RegError:
            break
        L.append(k)
        i = i + 1
    return L 
Example #11
Source File: msvccompiler.py    From Imogen with MIT License 6 votes vote down vote up
def read_keys(base, key):
    """Return list of registry keys."""
    try:
        handle = RegOpenKeyEx(base, key)
    except RegError:
        return None
    L = []
    i = 0
    while True:
        try:
            k = RegEnumKey(handle, i)
        except RegError:
            break
        L.append(k)
        i += 1
    return L 
Example #12
Source File: msvccompiler.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 6 votes vote down vote up
def read_keys(base, key):
    """Return list of registry keys."""
    try:
        handle = RegOpenKeyEx(base, key)
    except RegError:
        return None
    L = []
    i = 0
    while True:
        try:
            k = RegEnumKey(handle, i)
        except RegError:
            break
        L.append(k)
        i += 1
    return L 
Example #13
Source File: msvccompiler.py    From Fluid-Designer with GNU General Public License v3.0 6 votes vote down vote up
def read_keys(base, key):
    """Return list of registry keys."""
    try:
        handle = RegOpenKeyEx(base, key)
    except RegError:
        return None
    L = []
    i = 0
    while True:
        try:
            k = RegEnumKey(handle, i)
        except RegError:
            break
        L.append(k)
        i += 1
    return L 
Example #14
Source File: msvccompiler.py    From android_universal with MIT License 6 votes vote down vote up
def read_keys(base, key):
    """Return list of registry keys."""
    try:
        handle = RegOpenKeyEx(base, key)
    except RegError:
        return None
    L = []
    i = 0
    while True:
        try:
            k = RegEnumKey(handle, i)
        except RegError:
            break
        L.append(k)
        i += 1
    return L 
Example #15
Source File: msvccompiler.py    From Fluid-Designer with GNU General Public License v3.0 6 votes vote down vote up
def read_keys(base, key):
    """Return list of registry keys."""
    try:
        handle = RegOpenKeyEx(base, key)
    except RegError:
        return None
    L = []
    i = 0
    while True:
        try:
            k = RegEnumKey(handle, i)
        except RegError:
            break
        L.append(k)
        i += 1
    return L 
Example #16
Source File: msvccompiler.py    From oss-ftp with MIT License 6 votes vote down vote up
def read_keys(base, key):
    """Return list of registry keys."""

    try:
        handle = RegOpenKeyEx(base, key)
    except RegError:
        return None
    L = []
    i = 0
    while 1:
        try:
            k = RegEnumKey(handle, i)
        except RegError:
            break
        L.append(k)
        i = i + 1
    return L 
Example #17
Source File: msvccompiler.py    From canape with GNU General Public License v3.0 6 votes vote down vote up
def read_keys(base, key):
    """Return list of registry keys."""

    try:
        handle = RegOpenKeyEx(base, key)
    except RegError:
        return None
    L = []
    i = 0
    while 1:
        try:
            k = RegEnumKey(handle, i)
        except RegError:
            break
        L.append(k)
        i = i + 1
    return L 
Example #18
Source File: msvccompiler.py    From Computable with MIT License 6 votes vote down vote up
def read_keys(base, key):
    """Return list of registry keys."""

    try:
        handle = RegOpenKeyEx(base, key)
    except RegError:
        return None
    L = []
    i = 0
    while 1:
        try:
            k = RegEnumKey(handle, i)
        except RegError:
            break
        L.append(k)
        i = i + 1
    return L 
Example #19
Source File: msvccompiler.py    From medicare-demo with Apache License 2.0 6 votes vote down vote up
def read_keys(base, key):
    """Return list of registry keys."""

    try:
        handle = RegOpenKeyEx(base, key)
    except RegError:
        return None
    L = []
    i = 0
    while 1:
        try:
            k = RegEnumKey(handle, i)
        except RegError:
            break
        L.append(k)
        i = i + 1
    return L 
Example #20
Source File: msvccompiler.py    From BinderFilter with MIT License 6 votes vote down vote up
def read_keys(base, key):
    """Return list of registry keys."""

    try:
        handle = RegOpenKeyEx(base, key)
    except RegError:
        return None
    L = []
    i = 0
    while 1:
        try:
            k = RegEnumKey(handle, i)
        except RegError:
            break
        L.append(k)
        i = i + 1
    return L 
Example #21
Source File: msvccompiler.py    From CTFCrackTools with GNU General Public License v3.0 6 votes vote down vote up
def read_keys(base, key):
    """Return list of registry keys."""

    try:
        handle = RegOpenKeyEx(base, key)
    except RegError:
        return None
    L = []
    i = 0
    while 1:
        try:
            k = RegEnumKey(handle, i)
        except RegError:
            break
        L.append(k)
        i = i + 1
    return L 
Example #22
Source File: msvccompiler.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
def read_keys(base, key):
    """Return list of registry keys."""

    try:
        handle = RegOpenKeyEx(base, key)
    except RegError:
        return None
    L = []
    i = 0
    while 1:
        try:
            k = RegEnumKey(handle, i)
        except RegError:
            break
        L.append(k)
        i = i + 1
    return L 
Example #23
Source File: msvccompiler.py    From CTFCrackTools-V2 with GNU General Public License v3.0 6 votes vote down vote up
def read_keys(base, key):
    """Return list of registry keys."""

    try:
        handle = RegOpenKeyEx(base, key)
    except RegError:
        return None
    L = []
    i = 0
    while 1:
        try:
            k = RegEnumKey(handle, i)
        except RegError:
            break
        L.append(k)
        i = i + 1
    return L 
Example #24
Source File: win32serviceutil.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
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) 
Example #25
Source File: msvccompiler.py    From CTFCrackTools with GNU General Public License v3.0 6 votes vote down vote up
def read_keys(base, key):
    """Return list of registry keys."""

    try:
        handle = RegOpenKeyEx(base, key)
    except RegError:
        return None
    L = []
    i = 0
    while 1:
        try:
            k = RegEnumKey(handle, i)
        except RegError:
            break
        L.append(k)
        i = i + 1
    return L 
Example #26
Source File: toolmenu.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
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 
Example #27
Source File: regedit.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
def GetSubList(self):
		hkey = win32api.RegOpenKey(self.keyRoot, self.keyName)
		win32ui.DoWaitCursor(1)
		try:
			keyNum = 0
			ret = []
			while 1:
				try:
					key = win32api.RegEnumKey(hkey, keyNum)
				except win32api.error:
					break
				ret.append(HLIRegistryKey(self.keyRoot, self.keyName + "\\" + key, key))
				keyNum = keyNum + 1
		finally:
			win32api.RegCloseKey(hkey)
			win32ui.DoWaitCursor(0)
		return ret 
Example #28
Source File: browseProjects.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
def GetSubList(self):
		keyStr = regutil.BuildDefaultPythonKey() + "\\PythonPath"
		hKey = win32api.RegOpenKey(regutil.GetRootKey(), keyStr)
		try:
			ret = []
			ret.append(HLIProjectRoot("", "Standard Python Library")) # The core path.
			index = 0
			while 1:
				try:
					ret.append(HLIProjectRoot(win32api.RegEnumKey(hKey, index)))
					index = index + 1
				except win32api.error:
					break
			return ret
		finally:
			win32api.RegCloseKey(hKey) 
Example #29
Source File: msvccompiler.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def load_macros(self, version):
        vsbase = r"Software\Microsoft\VisualStudio\%0.1f" % version
        self.set_macro("VCInstallDir", vsbase + r"\Setup\VC", "productdir")
        self.set_macro("VSInstallDir", vsbase + r"\Setup\VS", "productdir")
        net = r"Software\Microsoft\.NETFramework"
        self.set_macro("FrameworkDir", net, "installroot")
        try:
            if version > 7.0:
                self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1")
            else:
                self.set_macro("FrameworkSDKDir", net, "sdkinstallroot")
        except KeyError:
            raise DistutilsPlatformError, \
                  ("""Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.""")

        p = r"Software\Microsoft\NET Framework Setup\Product"
        for base in HKEYS:
            try:
                h = RegOpenKeyEx(base, p)
            except RegError:
                continue
            key = RegEnumKey(h, 0)
            d = read_values(base, r"%s\%s" % (p, key))
            self.macros["$(FrameworkVersion)"] = d["version"] 
Example #30
Source File: msvccompiler.py    From unity-python with MIT License 5 votes vote down vote up
def load_macros(self, version):
        vsbase = r"Software\Microsoft\VisualStudio\%0.1f" % version
        self.set_macro("VCInstallDir", vsbase + r"\Setup\VC", "productdir")
        self.set_macro("VSInstallDir", vsbase + r"\Setup\VS", "productdir")
        net = r"Software\Microsoft\.NETFramework"
        self.set_macro("FrameworkDir", net, "installroot")
        try:
            if version > 7.0:
                self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1")
            else:
                self.set_macro("FrameworkSDKDir", net, "sdkinstallroot")
        except KeyError:
            raise DistutilsPlatformError, \
                  ("""Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.""")

        p = r"Software\Microsoft\NET Framework Setup\Product"
        for base in HKEYS:
            try:
                h = RegOpenKeyEx(base, p)
            except RegError:
                continue
            key = RegEnumKey(h, 0)
            d = read_values(base, r"%s\%s" % (p, key))
            self.macros["$(FrameworkVersion)"] = d["version"]