views:

37

answers:

2

Hey all,

I'm looking for a reliable way to determine the Windows OS architecture (32-bit or 64-bit) in a manner that isn't sensitive to Windows version or the system locale/display language. I will be using C# to do this. To clarify, I need the OS architecture, not the processor architecture, and not the application architecture.

I know I can use IntPtr.Size, but this is dependent on the application's target architecture.

I've also tried using System.Management.ManagementClass to get the "OSArchitecture" property from Win32_OperatingSystem. However, the value of this changes depending on the display language. (For example, if I set the display language to Spanish I get "64 bits", when in English it is "64-bit".)

Thanks!

+1  A: 

Here is an answer to How to detect Windows 64 bit platform with .net?

Basically, you can do this by first examining the type of the process and then call the proper method to do the correct check.

Svetlozar Angelov
Thanks for your help. This is probably what I'll end up going with eventually.
Tom
A: 

For anyone else who has the same question, this seems to do the trick as well. I'm not certain how robust it is:



public bool Is64Bit() {
    return (System.Environment.GetEnvironmentVariable("ProgramFiles(x86)") != null);
}


Tom