本文整理汇总了Python中win32api.RegOpenKey方法的典型用法代码示例。如果您正苦于以下问题:Python win32api.RegOpenKey方法的具体用法?Python win32api.RegOpenKey怎么用?Python win32api.RegOpenKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类win32api
的用法示例。
在下文中一共展示了win32api.RegOpenKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_regkey
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import RegOpenKey [as 别名]
def get_regkey(self):
try:
accessRead = win32con.KEY_READ | win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE
keyPath = 'Software\\Skype\\ProtectedStorage'
try:
hkey = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER, keyPath, 0, accessRead)
except Exception, e:
print e
return ''
num = win32api.RegQueryInfoKey(hkey)[1]
k = win32api.RegEnumValue(hkey, 0)
if k:
key = k[1]
return win32crypt.CryptUnprotectData(key, None, None, None, 0)[1]
示例2: GetSubList
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import RegOpenKey [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: UpdateForRegItem
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import RegOpenKey [as 别名]
def UpdateForRegItem(self, item):
self.DeleteAllItems()
hkey = win32api.RegOpenKey(item.keyRoot, item.keyName)
try:
valNum = 0
ret = []
while 1:
try:
res = win32api.RegEnumValue(hkey, valNum)
except win32api.error:
break
name = res[0]
if not name: name = "(Default)"
self.InsertItem(valNum, name)
self.SetItemText(valNum, 1, str(res[1]))
valNum = valNum + 1
finally:
win32api.RegCloseKey(hkey)
示例4: WriteToolMenuItems
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import RegOpenKey [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 RegOpenKey [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 RegOpenKey [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: get_regkey
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import RegOpenKey [as 别名]
def get_regkey(self):
try:
accessRead = win32con.KEY_READ | win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE
keyPath = 'Software\\Skype\\ProtectedStorage'
try:
hkey = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER, keyPath, 0, accessRead)
except Exception, e:
# print e
return ''
num = win32api.RegQueryInfoKey(hkey)[1]
k = win32api.RegEnumValue(hkey, 0)
if k:
key = k[1]
return win32crypt.CryptUnprotectData(key, None, None, None, 0)[1]
示例8: check_winscp_installed
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import RegOpenKey [as 别名]
def check_winscp_installed(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\Configuration\Security', 0, accessRead)
return True
except Exception, e:
return False
示例9: check_masterPassword
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import RegOpenKey [as 别名]
def check_masterPassword(self):
accessRead = win32con.KEY_READ | win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE
key = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER, 'Software\Martin Prikryl\WinSCP 2\Configuration\Security',
0, accessRead)
thisName = str(win32api.RegQueryValueEx(key, 'UseMasterPassword')[0])
if thisName == '0':
return False
else:
return True
示例10: get_logins_info
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import RegOpenKey [as 别名]
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:
return False
示例11: get_default_database
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import RegOpenKey [as 别名]
def get_default_database(self):
accessRead = win32con.KEY_READ | win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE
key = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER, 'Software\\ACS\\PuTTY Connection Manager', 0, accessRead)
thisName = str(win32api.RegQueryValueEx(key, 'DefaultDatabase')[0])
if thisName:
return thisName
else:
return ' '
示例12: run
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import RegOpenKey [as 别名]
def run(self):
accessRead = win32con.KEY_READ | win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE
keyPath = 'Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows Messaging Subsystem\\Profiles\\Outlook'
try:
hkey = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER, keyPath, 0, accessRead)
except Exception, e:
return
示例13: GetItemsCurrentValue
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import RegOpenKey [as 别名]
def GetItemsCurrentValue(self, item, valueName):
hkey = win32api.RegOpenKey(item.keyRoot, item.keyName)
try:
val, type = win32api.RegQueryValueEx(hkey, valueName)
if type != win32con.REG_SZ:
raise TypeError("Only strings can be edited")
return val
finally:
win32api.RegCloseKey(hkey)
示例14: SetItemsCurrentValue
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import RegOpenKey [as 别名]
def SetItemsCurrentValue(self, item, valueName, value):
# ** Assumes already checked is a string.
hkey = win32api.RegOpenKey(item.keyRoot, item.keyName , 0, win32con.KEY_SET_VALUE)
try:
win32api.RegSetValueEx(hkey, valueName, 0, win32con.REG_SZ, value)
finally:
win32api.RegCloseKey(hkey)
示例15: IsExpandable
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import RegOpenKey [as 别名]
def IsExpandable(self):
# All keys are expandable, even if they currently have zero children.
return 1
## hkey = win32api.RegOpenKey(self.keyRoot, self.keyName)
## try:
## keys, vals, dt = win32api.RegQueryInfoKey(hkey)
## return (keys>0)
## finally:
## win32api.RegCloseKey(hkey)