C# – How to know the processor is 32 or 64 bits in C#


How to know my processor is 32 or 64 bits in C#?

Best Solution

You can query the WMI class Win32_Processor using System.Management.ManagementObject:

ManagementObject mo;
mo = new ManagementObject("Win32_Processor.DeviceID='CPU0'");
ushort i = (ushort)mo["Architecture"];

switch (i)
case 0:
  return "32 Bit";
case 9:
  return "64 Bit";

Take a look at the MSDN Library description for other processor codes.

A problem with this is that the user, who is running the program, needs privileges for viewing the WMI.