How to tell x64 from 32 bit via registry?

SoulAssassin

Diamond Member
Feb 1, 2001
6,135
2
0
So I'm working on merging two scripts I wrote, both do the same thing but one is for x64 and one is for 32-bit...drops different binaries. Having a little trouble finding an automated method for determining the flavor of the OS. Best I can find is checking for HKEY_LOCAL_MACHINE\Software\WOW6432node and if it exists then it's x64, if not it's 32-bit. It will probably work but I don't think it's 'clean'.

Anyone know of a better way to determine if it's 32 or 64 bit?


not sure if it's better to post this in OS, software for Windows or programming...I reserve the right to cross post this if I don't get any responses here. :)
 

Zach

Diamond Member
Oct 11, 1999
3,400
1
81
What about environment variables? PROCESSOR_ARCHITECTURE is what I've used.
 

Modelworks

Lifer
Feb 22, 2007
16,240
7
76
So I'm working on merging two scripts I wrote, both do the same thing but one is for x64 and one is for 32-bit...drops different binaries. Having a little trouble finding an automated method for determining the flavor of the OS. Best I can find is checking for HKEY_LOCAL_MACHINE\Software\WOW6432node and if it exists then it's x64, if not it's 32-bit. It will probably work but I don't think it's 'clean'.

Anyone know of a better way to determine if it's 32 or 64 bit?


not sure if it's better to post this in OS, software for Windows or programming...I reserve the right to cross post this if I don't get any responses here. :)

Easiest way of all is check for Program Files(x86) directory. It only exist on 64 bit.
 

her209

No Lifer
Oct 11, 2000
56,336
11
0
How about checking the CurrentVersion key located at:

HKLM\Software\Microsoft\Windows NT\Currentversion

I believe:

5.1 = Windows XP
5.2 = Windows XP x64

EDIT: Operating System Version
 
Last edited: