0

i need to get OsArchitecture means Bits of O/s , i used Win32_OperatingSystem but its "OsArchitecture "is not work for all type Operating System

ManagementObjectSearcher objOSDetails = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem");
           ManagementObjectCollection osDetailsCollection = objOSDetails.Get();
 foreach( ManagementObject mo in osDetailsCollection )
  {
    String  _operatingSysBits = mo["OSArchitecture"].ToString();

  }
Shantanu Gupta
  • 20,688
  • 54
  • 182
  • 286
  • 1
    possible duplicate of [How to detect Windows 64 bit platform with .net?](http://stackoverflow.com/questions/336633/how-to-detect-windows-64-bit-platform-with-net) – Powerlord Aug 25 '10 at 17:46

2 Answers2

1

Check IntPtr.Size. It will be 4 on a 32-bit platform, and 8 on a 64-bit platform (unless your process is running in 32bit mode).

Bob
  • 3,301
  • 1
  • 16
  • 11
0

for .NET 4.0 there is Environment.is64BitOperatingSystem

or

    ManagementObject Mo = new ManagementObject("Win32_Processor.DeviceID='CPU0'");
    object o = Mo["Architecture"];
    UInt16 sp = (UInt16)(o);

    if (sp == 0)
    {
        //86
    } else if (sp == 9)
    {
        //64
    }

    Mo.Dispose();
nilphilus
  • 590
  • 1
  • 5
  • 23