本文整理汇总了Python中win32api.RegEnumKey方法的典型用法代码示例。如果您正苦于以下问题:Python win32api.RegEnumKey方法的具体用法?Python win32api.RegEnumKey怎么用?Python win32api.RegEnumKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类win32api
的用法示例。
在下文中一共展示了win32api.RegEnumKey方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: read_keys
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import RegEnumKey [as 别名]
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
示例2: GetSubList
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import RegEnumKey [as 别名]
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)
示例3: GetSubList
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import RegEnumKey [as 别名]
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
示例4: WriteToolMenuItems
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import RegEnumKey [as 别名]
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
示例5: _GetServiceShortName
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import RegEnumKey [as 别名]
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
# Open a service given either it's long or short name.
示例6: __FindSvcDeps
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import RegEnumKey [as 别名]
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)
示例7: read_keys
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import RegEnumKey [as 别名]
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
示例8: deleteKey
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import RegEnumKey [as 别名]
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
示例9: load_macros
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import RegEnumKey [as 别名]
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"]