views:

479

answers:

4

I want to know, at run time, whether I'm running on 32 bit or 64 bit windows. The OSVERSIONINFOEX structure tells me the major and minor version, but I'm guessing I need the build numbers. Anyone know what they are?

A: 

You can get the build number already from the OSVERSIONINFOEX structure.

If you are a 32-bit process and want to know if you're running under WOW64 (ie., a 64-bit OS), call IsWow64Process(). (requires XP SP2 or later)

Michael Burr
+1  A: 

Assuming you're using C++, there's a very good OS detection class here.

jeffm
+3  A: 

If your application is compiled for 64-bit, then the answer's easy: you're running on 64-bit Windows.

If your application is compiled for 32-bit, you need to call IsWow64Process. This function is only exported on Windows XP or later; if you want to support earlier versions of Windows, you'll need to use GetProcAddress to get a pointer to this function.

Roger Lipscombe
A: 

I use WMI.

select * from Win32_OperatingSystem

Get the first instance, and then select the Version attribute. For WinXP, it returns 5.1.2600.