From: ptkwt@... (Phil Tomson) Date: 2003-12-30T12:36:47+09:00 Subject: Re: (FYI)Accessing WinXP-64bit registry items In article , Phil Tomson wrote: >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: > > KEY_WOW64_64KEY = 0x0100 > KEY_WOW64_32KEY = 0x0200 > >And then OR them into KEY_READ: > > KEY_READ = STANDARD_RIGHTS_READ | KEY_WOW64_64KEY | >KEY_WOW64_32KEY | > KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY > >After I did that it worked fine � I was able to see the 64bit registry >entries. > >How's that for obscure? ;-) > >You can find more info here: > >http://msdn.microsoft.com/library/default.asp?url=/library/enus/sysinfo/base/registry_key_security_and_access_rights.asp > >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? Phil