Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# How do you get the operating system architecture (x86 or x64)? [duplicate]

Possible Duplicate:
How to detect Windows 64 bit platform with .net?

How can I retrieve the operating system architecture (x86 or x64) with .NET 2.0?

I have not found any good method to get the OS architecture on Google. What I found was how to tell whether the process is 32-bit or 64-bit.

If there isn't anyway to find out in .NET 2.0 please tell me. :)

like image 397
xZerox Avatar asked Sep 03 '10 19:09

xZerox


1 Answers

Not the accepted answer in the duplicate question, but this is how I'd do it:

Use GetEnvironmentVariable to look for the PROCESSOR_ARCHITEW6432 variable. If it doesn't exist, you must be running 32bit:

bool is64bit = !string.IsNullOrEmpty(
    Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432"));
like image 121
djdd87 Avatar answered Oct 04 '22 22:10

djdd87