Friday, 12 December 2008

Stuff You'll Wish You'd Known When You Switched To 64-bit Windows

A pagoda at sunset in Kyoto, Japan. This has nothing to do with 64-bit Windows, but it is quite pretty.64-bit Windows is great. I've been running on XP 64 and Vista 64  for about a year now. My extremely old Canon USB scanner isn't supported, and I had to wait a long time for 64-bit drivers for my Line6 Pod XT, but otherwise everything works very nicely - and for running virtual PCs, the extra memory is really worth it.

That said, there's a couple of underlying differences that result in some very odd behaviour in day-to-day usage. It's important to realize that 32-bit and 64-bit Windows subsystems exist as parallel but separate environments. Confusingly, the 64-bit tools and utilities live in C:\Windows\System32, and their 32-bit counterparts live in C:\Windows\SysWOW64. 32-bit processes on x64 Windows are actually running inside a virtual environment, which redirects requests for underlying system resources for 32-bit processes.

64-bit Windows ships with 32-bit and 64-bit versions of lots of common applications - including Internet Explorer and the Windows Script Host. Check out the links below for some more detailed discussion of the architecture and reasoning behind this.

Internet Explorer

You'll find Internet Explorer and Internet Explorer (64 bit) in your Start menu. The 64-bit version can't see any 32-bit components - so no Flash player, no Java, no plugins, no ActiveX controls, nothing. This is useful for testing, but not much else.

Windows Scripting Host

If you run a Windows script (myscript.vbs) from cmd.exe or directly from Explorer, it'll run as a 64-bit process, which means it can't see any 32-bit COM objects like ADO connections and datasets. If you explicitly invoke it using C:\Windows\SysWOW64\cscript.exe, it'll run as a 32-bit process.

The Windows\System32 folder

64-bit apps - like the notepad.exe that ships with Windows - can see C:\Windows\System32\ and it's various subfolders. 32-bit apps - like TextPad - can't see this folder because Windows is "hiding" the system folders from the 32-bit process. This is completely baffling when you try to edit your /etc/hosts file using your normal editor and it appears to be completely missing - even though you had it open in Notepad a second ago. There's a thing called the sysnative file system redirector that you'll need to set up to be able to see these folders from 32-bit apps.

The Registry

The same caveat applies to the registry.  When a 32-bit app asks for a value stored under, say,

HKEY_LOCAL_MACHINE\Software\MyCompany\MyProject,

64-bit Windows will actually return the value from

 HKEY_LOCAL_MACHINE\Software\Wow6432Node\MyCompany\MyProject.

This is normally fine, because most 32-bit apps are installed by a 32-bit installer, so the redirection is in place both during install (when the keys are created) and at runtime (when they're used). If you're manually importing registry keys - e.g. by doubleclicking a .reg file - they'll import into the locations specified in the file, and then your 32-bit apps won't be able to find them. You'll need to manually copy the keys and values into the Wow6432Node subtree (or edit the original .reg file and re-import)

References

http://blogs.msdn.com/helloworld/archive/2007/12/12/activex-component-can-t-create-object-when-creating-a-32-com-object-in-a-64-bit-machine.aspx

http://blogs.sepago.de/helge/2008/03/11/windows-x64-all-the-same-yet-very-different-part-5/

1 comment:

NickG said...

You've really put me off trying a 64bit edition - I think I'll wait until 4GB definitely isn't enough RAM before upgrading!

4GB should be enough for anyone :)