Detect Vista 64-bit

Hi all,
I saw this sample code on how to detect Windows Vista & Longhorn on MSDN website but it doesn't show how to distinguish 32-bit and 64-bit versions. When I tried to get the processor architecture data on Intel Xeon system that has 32-bit Vista installed, the result I got back is PROCESSOR_ARCHITECTURE_AMD64, which is not correct. Could you help?
The sample codes on MSDN:
if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 )
{
if( osvi.wProductType == VER_NT_WORKSTATION )
printf ("Microsoft Windows Vista ");
else printf ("Windows Server \"Longhorn\" " );
}
Thanks!
[1328 byte] By [thuhaile] at [2007-12-25]
# 1

It's actually fairly easy.

1. see if you are on windows vista.

2a.if your code is 64bit, just return true in your function that checks to see if its a 64 bit os. Since native 64 bit code cant run on a 32bit os, the mere fact that your 64bit code is running signifies that you on are a 64bit os.

OR

2b. If you code is 32bit, use the IsWow64Process() api. This will let you know if you are running under the wow 64 emulator( wow64 is microsfts emulator that lets 32bit apps run on native 64bit os's ). Just be carefully to dynamically load IsWow64Process or delay load it, since the api function does not exist on all versions of windows.

Hope this helps.

JonnyDeep at 2007-10-8 > top of Msdn Tech,Software Development for Windows Vista,Windows SDK...
# 2
Thanks Jonny. The problem is I'm making a WMI call for remote computers as well. The information I got back from querying "Win32_Processor" WMI object is PROCESSOR_ARCHITECTURE_AMD64 for the processor value even though it is a 32-bit Vista. Do you happen to know the what I did wrong?
thuhaile at 2007-10-8 > top of Msdn Tech,Software Development for Windows Vista,Windows SDK...
# 3

If i had to take a guess i would say the processor is actually a 64 bit processor. 64 bit processors can run 32 bit editions of windows vista. Im not sure how exactly you would do this via WMI on a remote computer. My previous post will only show you how to get the vista 32/64 bit version of vista on the local machine.

JonnyDeep at 2007-10-8 > top of Msdn Tech,Software Development for Windows Vista,Windows SDK...
# 4

Hello JonnyDeep. I have a problem with my Windows Vista RC1 64-bit. Some programs are only able to run in the 32-bit version. Not even with the Program Compatibility Wizard worked. I would like to have an emulator that helps me to run these programs.

If you know of an application or a web link, please reply to my mail.

Thank You

DAVIDiniguez at 2007-10-8 > top of Msdn Tech,Software Development for Windows Vista,Windows SDK...
# 5
There is a built in 32bit emulator called wow64. There are no standalone emulators that I am aware of. Keep in mind that even though regular applications 32 bit applications can be emulated that drivers are not. All drivers used in windows vista are 64 bit. So if the program you are running installs a driver and expects that driver to work, it may fail. The driver does not have to be an actually hardware driver, can be a service driver too.. etc. Also, there may be some problems related to the mysteries of file redirection aswell. Most likely if you want these programs to run on 64 bit vista you are going to have to wait for an update from the creator of the program.
JonnyDeep at 2007-10-8 > top of Msdn Tech,Software Development for Windows Vista,Windows SDK...

Software Development for Windows Vista

Site Classified