Friday, May 11, 2007

How To View And Edit The Registry Under Windows 64-bit

I've been running Windows XP 64-bit for nearly a year and there is one gotcha that I run into when debugging COM applications, dealing with the registry. In 64-bit Windows the entire 32-bit registry is located under the key HKEY_LOCAL_MACHINE\Software\WOW6432Node. 32-bit Delphi applications can only see the 32-bit keys, but a 64-bit application can see everything. I use a 32-bit 4NT which launches the 32-bit regedit so if I want the 64-bit regedit I just go to the start menu, click Run and type "regedit". You can also run the 32-bit regedit from the start menu by going to the start menu, clicking Run and typing "%systemroot%\syswow64\regedit". You can only run one at a time unless you use the -m switch. This can get confusing fast because Windows On Windows 64 (WOW64) mirrors certain registry keys and values between the 64-bit and 32-bit registry. So if you are on Windows 64-bit, open up regedit and do some twiddling and then try to run your COM app and things don't work as you expect, make sure you are twiddling with the correct registry.

5 comments:

Matt said...

So how, in Delphi 7, would you edit the 64-Bit registry from a 32-bit application?

Chris Bensen said...

Matt, actually you can, but you need to jump through a lot of hoops to get access to the WOW64 registry from 32-bit.

Unknown said...

Chris so how would you edit the 64-Bit registry from a 32-bit application? I need to do this for an application now. This whole 64-bit stuff is really starting to bite me hard.

Chris Bensen said...

Charles, this should answer your question: http://msdn.microsoft.com/en-us/library/aa384129(v=VS.85).aspx

The overview of WOW64 is here:
http://msdn.microsoft.com/en-us/library/aa384249(VS.85).aspx

Unknown said...

Hi Chris, (the following is intended as light-hearted humour, but is also a question - it's just that I'm rapidly losing my ability to communicate effectively with human beings :-)

App1.Is32bit := True;
App2.Is32bit := True;
OnlyPC.Is64bit := True;

App1.WriteToReg(SameKey, WriteValue);
ReadValue := App2.ReadFromReg(SameKey);

// True or False question...
Answer1 := (ReadValue = WriteValue);

If SameKey.IsNotSameGoBackToWinXP then
begin
Career.ChangeTo('RealEstateAgent');
raise;
end;

Post a Comment