There probably aren’t a lot of WinXP-64bit users out there yet, but I
post this for future reference:
I was using the win32/registry (as in ‘require “win32/registry”’)
package to access the registry to figure out if certiain apps were
installed on a Windows box. The script worked fine on my Win2K box,
but when someone tried it on their WinXP-64bit edition box it didn’t
find the installed apps as it should have.
Turns out that in 64bit windows there are two sections to the
registry, a 32bit section and a 64bit section. I couldn’t see the
64bit apps from the Ruby script (using the standard Ruby install
created by Andy Hunt, so it’s 32 bits). After some research, I found
out that you’ve got to add some new registry access rights.
The solution is that you need to add some new access rights keys in
your Win32::Registry::Constants module:
I’ve notified Usa Nakamura who I’m told is the registry.rb maintainer,
so hopefully, by the time you need this in the 64bit future it will
work OK out of the box.
There probably aren’t a lot of WinXP-64bit users out there yet, but I
post this for future reference:
I was using the win32/registry (as in ‘require “win32/registry”’)
package to access the registry to figure out if certiain apps were
installed on a Windows box. The script worked fine on my Win2K box,
but when someone tried it on their WinXP-64bit edition box it didn’t
find the installed apps as it should have.
Turns out that in 64bit windows there are two sections to the
registry, a 32bit section and a 64bit section. I couldn’t see the
64bit apps from the Ruby script (using the standard Ruby install
created by Andy Hunt, so it’s 32 bits). After some research, I found
out that you’ve got to add some new registry access rights.
The solution is that you need to add some new access rights keys in
your Win32::Registry::Constants module:
I’ve notified Usa Nakamura who I’m told is the registry.rb maintainer,
so hopefully, by the time you need this in the 64bit future it will
work OK out of the box.
Well, I spoke a bit too soon… Sure it works on 64-bit Windows, but it
breaks now on 32-bit Windows.
Looks like we need to come up with some reliable way to determine if
you’re running on 64bit WinXP or 32Bit WinXP and then do something like:
KEY_READ |= (KEY_WOW64_64KEY | KEY_WOW64_32KEY) if XP64
There probably aren’t a lot of WinXP-64bit users out there yet, but I
post this for future reference:
I was using the win32/registry (as in ‘require “win32/registry”’)
package to access the registry to figure out if certiain apps were
installed on a Windows box. The script worked fine on my Win2K box,
but when someone tried it on their WinXP-64bit edition box it didn’t
find the installed apps as it should have.
Turns out that in 64bit windows there are two sections to the
registry, a 32bit section and a 64bit section. I couldn’t see the
64bit apps from the Ruby script (using the standard Ruby install
created by Andy Hunt, so it’s 32 bits). After some research, I found
out that you’ve got to add some new registry access rights.
The solution is that you need to add some new access rights keys in
your Win32::Registry::Constants module:
I’ve notified Usa Nakamura who I’m told is the registry.rb maintainer,
so hopefully, by the time you need this in the 64bit future it will
work OK out of the box.
Well, I spoke a bit too soon… Sure it works on 64-bit Windows, but it
breaks now on 32-bit Windows.
Looks like we need to come up with some reliable way to determine if
you’re running on 64bit WinXP or 32Bit WinXP and then do something like:
KEY_READ |= (KEY_WOW64_64KEY | KEY_WOW64_32KEY) if XP64
Any ideas for how to determine XP64?
Here’s what I had to do to determine if the script is running on
WinXP64 (changes to win32/registry.rb):
require ‘Win32API’
module Win32
class Registry
module Constants #since IsWow64Process only exists on XP we need to do #a rescue in case we’re not running on an XP machine:
begin
IsWow64Process=Win32API.new(“kernel32”,“IsWow64Process”,[‘L’,‘P’],‘L’)
rescue
puts “you’re not on XP” if $DEBUG
isXP = false
else
puts “you’re on XP: could be 32 or 64 bit” if $DEBUG
isXP = true
end
GetCurrentProcess =
Win32API.new(“kernel32”,“GetCurrentProcess”,,‘L’)
#
KEY_WOW64_64KEY = 0x0100
KEY_WOW64_32KEY = 0x0200
key_read = STANDARD_RIGHTS_READ |
KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY
if isXP
is64 = ""
result = IsWow64Process.call(GetCurrentProcess.call(),is64)
is64 = true if is64.unpack("c")[0].to_i != 0
if is64
puts "This script is running on WinXP 64bit edition" if
$DEBUG
key_read |= (KEY_WOW64_64KEY | KEY_WOW64_32KEY )
end
end
KEY_READ = key_read