Module: Puppet::Util::Windows::Registry
- Defined in:
- lib/puppet/util/windows/registry.rb
Constant Summary collapse
- KEY64 =
0x100- KEY32 =
0x200- KEY_READ =
0x20019- KEY_WRITE =
0x20006- KEY_ALL_ACCESS =
0x2003f
Instance Method Summary collapse
- #open(name, path, mode = KEY_READ | KEY64, &block) ⇒ Object
- #root(name) ⇒ Object
- #values(subkey) ⇒ Object
Instance Method Details
#open(name, path, mode = KEY_READ | KEY64, &block) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/puppet/util/windows/registry.rb', line 19 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 '#{hkey.keyname}\\#{path}'", error.code, error) end end |
#root(name) ⇒ Object
13 14 15 16 17 |
# File 'lib/puppet/util/windows/registry.rb', line 13 def root(name) Win32::Registry.const_get(name) rescue NameError raise Puppet::Error, "Invalid registry key '#{name}'", $!.backtrace end |
#values(subkey) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/puppet/util/windows/registry.rb', line 30 def values(subkey) values = {} subkey.each_value do |name, type, data| case type when Win32::Registry::REG_MULTI_SZ data.each { |str| force_encoding(str) } when Win32::Registry::REG_SZ, Win32::Registry::REG_EXPAND_SZ force_encoding(data) end values[name] = data end values end |