我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用_winreg.QueryValueEx()。
def windefnd_running(): key = False if reg_exists('SOFTWARE\\Policies\\Microsoft\\Windows Defender'): key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,'SOFTWARE\\Policies\\Microsoft\\Windows Defender') elif reg_exists('SOFTWARE\\Microsoft\\Windows Defender'): key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,'SOFTWARE\\Microsoft\\Windows Defender') if key: try: val=_winreg.QueryValueEx(key, "DisableAntiSpyware") if val[0] == 1: return False else: return True except: return False print "BROKEEEEEEN"
def sunvirtual_scan(services,luid,dsys,dsdtkey,fadtkey): #print "Scanning for Sun VirtualBox..." virtpc_svc = ['VBoxMouse','VBoxGuest','VBoxService','VBoxSF'] for s in virtpc_svc: if s in services : return ("VM Scan Complete: This is a Sun VirtualBox Virtual Machine.") if luid: iD =_winreg.QueryValueEx(luid, 'Identifier') if 'vbox' in str(iD[0]).lower(): return ("VM Scan Complete: This is a Sun VirtualBox Virtual Machine.") if dsys: sysbios =_winreg.QueryValueEx(dsys, 'SystemBiosVersion') if 'vbox' in str(sysbios[0]).lower(): return ("VM Scan Complete: This is a Sun VirtualBox Virtual Machine.") if "VBOX__" in dsdtkey or "VBOX__" in fadtkey: return ("VM Scan Complete: This is a Sun VirtualBox Virtual Machine.") return False
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
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
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
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
def _get_reg_value(key, subkey, name): """Return registry value specified by key, subkey, and name. Environment variables in values of type REG_EXPAND_SZ are expanded if possible. """ key = _winreg.OpenKey(key, subkey) try: ret = _winreg.QueryValueEx(key, name) except WindowsError: return None else: key.Close() if ret[1] == _winreg.REG_EXPAND_SZ: return expandvars(ret[0]) else: return ret[0]
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
def _RegistryGetValueUsingWinReg(key, value): """Use the _winreg module to obtain the value of a registry key. Args: key: The registry key. value: The particular registry value to read. Return: contents of the registry key's value, or None on failure. Throws ImportError if _winreg is unavailable. """ import _winreg try: root, subkey = key.split('\\', 1) assert root == 'HKLM' # Only need HKLM for now. with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, subkey) as hkey: return _winreg.QueryValueEx(hkey, value)[0] except WindowsError: return None