but would like to query the registry from ruby. Just thinking outloud
here, haven’t found a tutorial invovling the registry and ruby which I
find useful yet
C:\msi>
C:\msi>
C:\msi>dir
Volume in drive C has no label.
Volume Serial Number is 0491-510F
but would like to query the registry from ruby. Just thinking outloud
here, haven’t found a tutorial invovling the registry and ruby which I
find useful yet
The following is what I was able to figure out from the standard
library API docs at RDoc Documentation. It’s pretty
Rubyish once you get going.
[in irb]
irb> require ‘win32/registry’
irb> include Win32
irb> Registry.open(Registry::HKEY_LOCAL_MACHINE, ‘Software\Policies
\Microsoft\Windows\Installer’).each_value do |subkey, type, data|
irb* puts “#{subkey} (#{type}): #{data}”
irb> end
The only problem I see with this is that you get the constant value
for type (4 in this case) rather than the constant name (REG_DWORD).
Is that what you were wanting to do?
I don’t have this key on my machine. Only HKEY_CURRENT_USER\Software
\Policies\Microsoft\SystemCertificates which has subkeys, but no
values, but all keys should be similar to the above.
def each_value
index = 0
while true
begin
subkey = API.EnumValue(@hkey, index)
rescue Error
break
end
begin
type, data = read(subkey)
rescue Error
next
end
yield subkey, type, data
index += 1
end
index
end