I am using ruby 32 bit in my application. I am using "win32/registry" for reading registry keys.
When i use
reg = Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\app_path')
reg_typ, reg_val = reg.read('somekey')
It by default reads in path
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\app_path
.
Now some of the applications are 64 bit and I want to check for
HKEY_LOCAL_MACHINE\SOFTWARE\app_path
h. But, by default it always try to find under "WOW6432Node"
Any suggestion on what I am missing and how can i read registry for both 32 and 64 bit applications from ruby?
Apparently win32/registry
is not defining the KEY_WOW64_{32,64}KEY
flags which are used to do that. But since Ruby allows re-opening classes and modules you can easily add them on your own:
module Win32::Registry::Constants
KEY_WOW64_64KEY = 0x0100
KEY_WOW64_32KEY = 0x0200
end
To read a 64-bit key:
reg = Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\app_path',
Win32::Registry::KEY_READ | Win32::Registry::KEY_WOW64_64KEY)
To read a 32-bit key:
reg = Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\app_path',
Win32::Registry::KEY_READ | Win32::Registry::KEY_WOW64_32KEY)
You can open a feature request for that on Ruby's bug tracker (or I can do it for you if you prefer).