wslwinreg
Loading...
Searching...
No Matches
wslwinreg.WinRegKey Class Reference

Registry key helper class. More...

Public Member Functions

 __init__ (self, root_key, subkey, access)
 Initialize the class.
 __enter__ (self)
 Enable enter/exit functionality.
 __exit__ (self, exception_type, exception_value, traceback)
 Release resources on class release.
 close (self)
 Release existing key, if any.
 open_subkey (self, subkey, access=None)
 Open a sub key.
 get_subkeys (self)
 Return the list of all of the sub key names.
 get_value (self, value_name=None)
 Read a value from a registry key.
 get_all_values (self)
 Return a dict of all key name and associated values.
 __getitem__ (self, subkey)
 Call open_subkey() with subscript.
 __iter__ (self)
 Iterator of the sub keys.

Public Attributes

 key = root_key
 Key handle of opened key.
 access = access
 Access used to open this key, used as default to open sub keys.

Detailed Description

Registry key helper class.

Manage entries in a registy key by using indexing and scanning.

Constructor & Destructor Documentation

◆ __init__()

wslwinreg.WinRegKey.__init__ ( self,
root_key,
subkey,
access )

Initialize the class.

Parameters
root_keyRoot key enumeration
subkeyString or None for name of sub key
accessAccess flags to pass to OpenKeyEx()

Member Function Documentation

◆ __exit__()

wslwinreg.WinRegKey.__exit__ ( self,
exception_type,
exception_value,
traceback )

Release resources on class release.

Parameters
exception_typeIgnored
exception_valueIgnored
tracebackIgnored

◆ __getitem__()

wslwinreg.WinRegKey.__getitem__ ( self,
subkey )

Call open_subkey() with subscript.

  Uses the access flags from this key to open the sub key.
Parameters
subkeyRequested sub key.
Returns
An instance of the WinRegKey of the new key.

◆ __iter__()

wslwinreg.WinRegKey.__iter__ ( self)

Iterator of the sub keys.

  Call get_subkeys() and encapsulate the value in an iter()
Returns
iter of get_subkeys()

◆ get_all_values()

wslwinreg.WinRegKey.get_all_values ( self)

Return a dict of all key name and associated values.

Returns
dict with each item is the returned value from QueryValueEx()

◆ get_subkeys()

wslwinreg.WinRegKey.get_subkeys ( self)

Return the list of all of the sub key names.

  Iterate over all of the sub keys and place their names in a list.
  Return the list. Unicode is properly handled.
Returns
list of names of all the subkeys.

◆ get_value()

wslwinreg.WinRegKey.get_value ( self,
value_name = None )

Read a value from a registry key.

Note
If the type returned is REG_SZ, scan for a null and trucate. If the type returned is REG_EXPAND_SZ, call
ExpandEnvironmentStrings()
Parameters
value_nameString of the name of the value, None for default.
Returns
Value returned from QueryValueEx()

◆ open_subkey()

wslwinreg.WinRegKey.open_subkey ( self,
subkey,
access = None )

Open a sub key.

Parameters
subkeyName of the subkey to open
accessDesired access to the subkey.
Returns
An instance of the WinRegKey of the new key.