Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can my program determine if it is running on 32-bit or 64-bit Windows?

Here's my question. What is the best way to determine what bit architecture your app is running on?

What I am looking to do: On a 64 bit server I want my app to read 64 bit datasources (stored in reg key Software\Wow6432Node\ODBC\ODBC.INI\ODBC Data Sources) and if its 32 bit I want to read 32 bit datasources, (i.e. Read from Software\ODBC\ODBC.INI\ODBC Data Sources).

I might be missing the point, but I don't want to care what mode my app is running in. I simply want to know if the OS is 32 or 64 bit.

[System.Environment.OSVersion.Platform doesn't seem to be cutting it for me. Its returning Win32NT on my local xp machine and on a win2k8 64 bit server (even when all my projects are set to target 'any cpu')]

like image 260
user48408 Avatar asked May 19 '10 15:05

user48408


People also ask

How do you tell if an installed program is 32 or 64-bit?

The easiest way, without installing another program or running the file, is just to right click on the file, choose Properties, and then go the the Compatibility tab. If there are no greyed out options and Windows XP and 9x modes are offered, it's 32-bit.

How do you find out if a program is 32 or 64-bit Windows 10?

Launch the target program you want to check if it's 32-bit or 64-bit, then open Task Manager and go to the Details tab. Right-click on a column header and choose Select columns. Check the Platform box, and click OK. Under the Platform column, you can easily see if a particular program on you system is 32-bit or 64-bit.

How do I know if I am running x86 or x64?

Open the Settings app. Navigate to System > About. On the right, check out the System type value. It shows either a x86-based processor (32-bit), x64-based processor (64-bit), or ARM-based processor depending on the hardware you have.


2 Answers

You shouldn't even worry about this, normally. The system automatically redirects registry queries to Software\Wow6432Node when running a 32-bit app on a 64-bit platform.

like image 144
JSBձոգչ Avatar answered Oct 18 '22 03:10

JSBձոգչ


Try the property Environment.Is64BitOperatingSystem. This is a new one added in .Net 4.0 specifically for the purpose of checking the type of the operating system.

like image 25
JaredPar Avatar answered Oct 18 '22 05:10

JaredPar