Module: Puppet::Util::Windows::Registry Private
- Extended by:
- FFI::Library
- Defined in:
- lib/puppet/util/windows.rb,
lib/puppet/util/windows/registry.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- KEY64 =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
msdn.microsoft.com/en-us/library/windows/desktop/aa384129(v=vs.85).aspx
0x100
- KEY32 =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
0x200
- KEY_READ =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
0x20019
- KEY_WRITE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
0x20006
- KEY_ALL_ACCESS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
0x2003f
- ERROR_NO_MORE_ITEMS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
259
Instance Method Summary collapse
- #delete_key(key, subkey_name, mode = KEY64) ⇒ Object private
- #delete_value(key, subkey_name) ⇒ Object private
-
#each_key(key, &block) ⇒ Object
private
subkey is String which contains name of subkey.
- #each_value(key, &block) ⇒ Object private
- #keys(key) ⇒ Object private
- #open(name, path, mode = KEY_READ | KEY64, &block) ⇒ Object private
- #root(name) ⇒ Object private
- #values(key) ⇒ Object private
-
#values_by_name(key, names) ⇒ Hashtable<String, Object>
private
Retrieve a set of values from a registry key given their names Value names listed but not found in the registry will not be added to the resultant Hashtable.
Instance Method Details
#delete_key(key, subkey_name, mode = KEY64) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
59 60 61 |
# File 'lib/puppet/util/windows/registry.rb', line 59 def delete_key(key, subkey_name, mode = KEY64) reg_delete_key_ex(key, subkey_name, mode) end |
#delete_value(key, subkey_name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
107 108 109 |
# File 'lib/puppet/util/windows/registry.rb', line 107 def delete_value(key, subkey_name) reg_delete_value(key, subkey_name) end |
#each_key(key, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
subkey is String which contains name of subkey. wtime is last write time as FILETIME (64-bit integer). (see Registry.wtime2time)
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/puppet/util/windows/registry.rb', line 43 def each_key(key, &block) index = 0 subkey = nil subkey_max_len, _ = reg_query_info_key_max_lengths(key) loop do subkey, filetime = reg_enum_key(key, index, subkey_max_len) yield subkey, filetime if !subkey.nil? index += 1 break if subkey.nil? end index end |
#each_value(key, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/puppet/util/windows/registry.rb', line 91 def each_value(key, &block) index = 0 subkey = nil _, value_max_len = reg_query_info_key_max_lengths(key) loop do subkey, type, data = reg_enum_value(key, index, value_max_len) yield subkey, type, data if !subkey.nil? index += 1 break if subkey.nil? end index end |
#keys(key) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
35 36 37 38 39 |
# File 'lib/puppet/util/windows/registry.rb', line 35 def keys(key) keys = {} each_key(key) { |subkey, filetime| keys[subkey] = filetime } keys end |
#open(name, path, mode = KEY_READ | KEY64, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/puppet/util/windows/registry.rb', line 24 def open(name, path, mode = KEY_READ | KEY64, &block) hkey = root(name) begin hkey.open(path, mode) do |subkey| return yield subkey end rescue Win32::Registry::Error => error raise Puppet::Util::Windows::Error.new(_("Failed to open registry key '%{key}\\%{path}'") % { key: hkey.keyname, path: path }, error.code, error) end end |
#root(name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 21 22 |
# File 'lib/puppet/util/windows/registry.rb', line 18 def root(name) Win32::Registry.const_get(name) rescue NameError raise Puppet::Error, _("Invalid registry key '%{name}'") % { name: name }, $!.backtrace end |
#values(key) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
63 64 65 66 67 |
# File 'lib/puppet/util/windows/registry.rb', line 63 def values(key) vals = {} each_value(key) { |subkey, type, data| vals[subkey] = data } vals end |
#values_by_name(key, names) ⇒ Hashtable<String, Object>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Retrieve a set of values from a registry key given their names Value names listed but not found in the registry will not be added to the resultant Hashtable
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/puppet/util/windows/registry.rb', line 76 def values_by_name(key, names) vals = {} names.each do |name| FFI::Pointer.from_string_to_wide_string(name) do |subkeyname_ptr| begin _, vals[name] = read(key, subkeyname_ptr) rescue Puppet::Util::Windows::Error => e # ignore missing names, but raise other errors raise e unless e.code == Puppet::Util::Windows::Error::ERROR_FILE_NOT_FOUND end end end vals end |