c# 判断操作系统位数

需要引用 using System.Management;

public static string Detect3264()

        {
            string addressWidth = String.Empty;
            ConnectionOptions mConnOption = new ConnectionOptions();
            ManagementScope mMs = new ManagementScope(@"\\localhost", mConnOption);
            ObjectQuery mQuery = new ObjectQuery("select AddressWidth from Win32_Processor");
            ManagementObjectSearcher mSearcher = new ManagementObjectSearcher(mMs, mQuery);
            ManagementObjectCollection mObjectCollection = mSearcher.Get(); 
            foreach (ManagementObject oReturn in mObjectCollection)
            {
                addressWidth = oReturn["AddressWidth"].ToString();
            }


            return addressWidth;

        } 

 

你可能感兴趣的:(C#)