本文整理匯總了Python中_winreg.QueryValueEx方法的典型用法代碼示例。如果您正苦於以下問題:Python _winreg.QueryValueEx方法的具體用法?Python _winreg.QueryValueEx怎麽用?Python _winreg.QueryValueEx使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類_winreg
的用法示例。
在下文中一共展示了_winreg.QueryValueEx方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: WIN_get_device_guid
# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import QueryValueEx [as 別名]
def WIN_get_device_guid(self):
try:
regkey = registry.OpenKey(registry.HKEY_LOCAL_MACHINE, self.WINDOWS_ADAPTER_KEY)
for i in xrange(10000):
key_name = registry.EnumKey(regkey, i)
try:
regsubkey = registry.OpenKey(regkey, key_name)
component_id = registry.QueryValueEx(regsubkey, "ComponentId")[0]
if component_id == self.TUNTAP_COMPONENT_ID:
return registry.QueryValueEx(regsubkey, 'NetCfgInstanceId')[0]
except WindowsError as e:
pass
continue
except Exception as e:
pass
return None
return None
示例2: getPathFromRegistry
# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import QueryValueEx [as 別名]
def getPathFromRegistry():
registryPath = r"Software\Microsoft\Windows\CurrentVersion\App Paths\trelby.exe"
try:
import _winreg
regPathKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, registryPath)
regPathValue, regPathType = _winreg.QueryValueEx(regPathKey, "Path")
if regPathType == _winreg.REG_SZ:
return regPathValue
else:
raise TypeError
except:
wx.MessageBox("There was an error reading the following registry key: %s.\n"
"You may need to reinstall the program to fix this error." %
registryPath, "Error", wx.OK)
sys.exit()
# convert s, which is returned from the wxWidgets GUI and is an Unicode
# string, to a normal string.
示例3: _get_win_folder_from_registry
# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import QueryValueEx [as 別名]
def _get_win_folder_from_registry(csidl_name):
"""This is a fallback technique at best. I'm not sure if using the
registry for this guarantees us the correct answer for all CSIDL_*
names.
"""
import _winreg
shell_folder_name = {
"CSIDL_APPDATA": "AppData",
"CSIDL_COMMON_APPDATA": "Common AppData",
"CSIDL_LOCAL_APPDATA": "Local AppData",
}[csidl_name]
key = _winreg.OpenKey(
_winreg.HKEY_CURRENT_USER,
r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
)
dir, type = _winreg.QueryValueEx(key, shell_folder_name)
return dir
示例4: _get_win_folder_from_registry
# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import QueryValueEx [as 別名]
def _get_win_folder_from_registry(csidl_name):
"""
This is a fallback technique at best. I'm not sure if using the
registry for this guarantees us the correct answer for all CSIDL_*
names.
"""
import _winreg
shell_folder_name = {
"CSIDL_APPDATA": "AppData",
"CSIDL_COMMON_APPDATA": "Common AppData",
"CSIDL_LOCAL_APPDATA": "Local AppData",
}[csidl_name]
key = _winreg.OpenKey(
_winreg.HKEY_CURRENT_USER,
r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
)
directory, _type = _winreg.QueryValueEx(key, shell_folder_name)
return directory
示例5: _win32_getvalue
# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import QueryValueEx [as 別名]
def _win32_getvalue(key,name,default=''):
""" Read a value for name from the registry key.
In case this fails, default is returned.
"""
try:
# Use win32api if available
from win32api import RegQueryValueEx
except ImportError:
# On Python 2.0 and later, emulate using _winreg
import _winreg
RegQueryValueEx = _winreg.QueryValueEx
try:
return RegQueryValueEx(key,name)
except:
return default
示例6: _get_win_folder_from_registry
# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import QueryValueEx [as 別名]
def _get_win_folder_from_registry(csidl_name):
"""This is a fallback technique at best. I'm not sure if using the
registry for this guarantees us the correct answer for all CSIDL_*
names.
"""
if PY3:
import winreg as _winreg
else:
import _winreg
shell_folder_name = {
"CSIDL_APPDATA": "AppData",
"CSIDL_COMMON_APPDATA": "Common AppData",
"CSIDL_LOCAL_APPDATA": "Local AppData",
}[csidl_name]
key = _winreg.OpenKey(
_winreg.HKEY_CURRENT_USER,
r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
)
dir, type = _winreg.QueryValueEx(key, shell_folder_name)
return dir
示例7: _get_win_folder_from_registry
# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import QueryValueEx [as 別名]
def _get_win_folder_from_registry(csidl_name):
"""
This is a fallback technique at best. I'm not sure if using the
registry for this guarantees us the correct answer for all CSIDL_*
names.
"""
import _winreg
shell_folder_name = {
"CSIDL_APPDATA": "AppData",
"CSIDL_COMMON_APPDATA": "Common AppData",
"CSIDL_LOCAL_APPDATA": "Local AppData",
}[csidl_name]
key = _winreg.OpenKey(
_winreg.HKEY_CURRENT_USER,
r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders",
)
directory, _type = _winreg.QueryValueEx(key, shell_folder_name)
return directory
示例8: get_device_guid
# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import QueryValueEx [as 別名]
def get_device_guid():
with reg.OpenKey(reg.HKEY_LOCAL_MACHINE, adapter_key) as adapters:
try:
for i in xrange(10000):
key_name = reg.EnumKey(adapters, i)
with reg.OpenKey(adapters, key_name) as adapter:
try:
component_id = reg.QueryValueEx(adapter, 'ComponentId')[0]
# print component_id
# if component_id == 'tap0801':
if component_id == 'tap0901':
regid = reg.QueryValueEx(adapter, 'NetCfgInstanceId')[0]
return 'regid:', regid
except WindowsError, err:
pass
except WindowsError, err:
pass
示例9: teardown_environment
# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import QueryValueEx [as 別名]
def teardown_environment():
"""Restore things that were remembered by the setup_environment function
"""
(oldenv, os.name, sys.platform, path.get_home_dir, IPython.__file__, old_wd) = oldstuff
os.chdir(old_wd)
reload(path)
for key in env.keys():
if key not in oldenv:
del env[key]
env.update(oldenv)
if hasattr(sys, 'frozen'):
del sys.frozen
if os.name == 'nt':
(wreg.OpenKey, wreg.QueryValueEx,) = platformstuff
# Build decorator that uses the setup_environment/setup_environment
示例10: test_get_home_dir_8
# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import QueryValueEx [as 別名]
def test_get_home_dir_8():
"""Using registry hack for 'My Documents', os=='nt'
HOMESHARE, HOMEDRIVE, HOMEPATH, USERPROFILE and others are missing.
"""
os.name = 'nt'
# Remove from stub environment all keys that may be set
for key in ['HOME', 'HOMESHARE', 'HOMEDRIVE', 'HOMEPATH', 'USERPROFILE']:
env.pop(key, None)
#Stub windows registry functions
def OpenKey(x, y):
class key:
def Close(self):
pass
return key()
def QueryValueEx(x, y):
return [abspath(HOME_TEST_DIR)]
wreg.OpenKey = OpenKey
wreg.QueryValueEx = QueryValueEx
home_dir = path.get_home_dir()
nt.assert_equal(home_dir, abspath(HOME_TEST_DIR))
示例11: _get_labview_paths_windows
# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import QueryValueEx [as 別名]
def _get_labview_paths_windows(self):
# Connect to the registry at the root of the LabVIEW key
import _winreg
reg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)
installed_lv_paths = []
# Iterate over all subkeys until you find one that isn't a version
# number. Each subkey represents a currently installed version of
# LabVIEW. We want to pull from that the key indicating its install
# path. We put each one into an array
for root_key in [r"SOFTWARE\Wow6432Node\National Instruments\LabVIEW",
r"SOFTWARE\National Instruments\LabVIEW"]:
try:
key = self._open_windows_native_key(reg, root_key)
i = 0
current_lv_version = _winreg.EnumKey(key, i)
while current_lv_version.find('.') != -1:
try:
current_lv_reg_key = self._open_windows_native_key(
reg, root_key + "\\" + current_lv_version)
value, key_type = _winreg.QueryValueEx(
current_lv_reg_key, "PATH")
except WindowsError as e:
if e.errno == 2:
pass
else:
installed_lv_paths.append(value)
finally:
i += 1
try:
current_lv_version = _winreg.EnumKey(key, i)
except (IOError, WindowsError):
break
except WindowsError as e:
# If the key doesn't exist LabVIEW may not be installed. We
# can safely ignore this error
pass
return installed_lv_paths