开发者

how to get Operating System Details in C# code

i need to get OsArchitecture means Bits of O/s , i used Win32_OperatingSys开发者_C百科tem 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();

  }


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).


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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜