我需要获得OsArchitecture意味着O / s的比特,我使用的是Win32_OperatingSystem,但它的“OsArchitecture”并不适用于所有类型的操作系统
ManagementObjectSearcher objOSDetails = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem");
ManagementObjectCollection osDetailsCollection = objOSDetails.Get();
foreach( ManagementObject mo in osDetailsCollection )
{
String _operatingSysBits = mo["OSArchitecture"].ToString();
}
答案 0 :(得分:1)
检查IntPtr.Size。它在32位平台上为4,在64位平台上为8(除非您的进程在32位模式下运行)。
答案 1 :(得分:0)
对于.NET 4.0,有Environment.is64BitOperatingSystem
或
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();