Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I tell if my application is running as a 32-bit or 64-bit application?

Tags:

c#

64-bit

32-bit

How do I tell if my application (compiled in Visual Studio 2008 as Any CPU) is running as a 32-bit or 64-bit application?

like image 248
Lawrence Johnston Avatar asked Nov 05 '08 18:11

Lawrence Johnston


People also ask

How do you tell if an app 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.

Can 32-bit applications run on a 64-bit PC?

Can I run 32-bit programs on a 64-bit computer? Most programs made for the 32-bit version of Windows will work on the 64-bit version of Windows except for most Antivirus programs. Device drivers that are made for the 32-bit version of Windows will not work correctly on a computer running a 64-bit version of Windows.


2 Answers

If you're using .NET 4.0, it's a one-liner for the current process:

Environment.Is64BitProcess

Reference: Environment.Is64BitProcess Property (MSDN)

like image 89
Sam Avatar answered Oct 23 '22 06:10

Sam


if (IntPtr.Size == 8) 
{
    // 64 bit machine
} 
else if (IntPtr.Size == 4) 
{
    // 32 bit machine
}
like image 71
Perica Zivkovic Avatar answered Oct 23 '22 07:10

Perica Zivkovic