国产97色在线|亚洲-欧美人妻另类制服丝袜-欧美人成国产91视频-殷素素一女战二夫|www.ycjrc.net

判斷操作系統(tǒng)是32位還是64位

發(fā)布時(shí)間:2016-12-29 22:25 作者:獨(dú)孤劍 閱讀:1016


引入System.Management,再引用


usingSystem;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

usingSystem.Data;

usingSystem.Drawing;

usingSystem.Text;

usingSystem.Windows.Forms;

usingSystem.Management;

 

namespaceWindowsFormsApplication1

{

   public partialclass Form1: Form

   {

       public Form1()

       {

            InitializeComponent();

       }

 

       private voidbutton1_Click(object sender, EventArgs e)

       {

            //AddressWidth返回值

            //32bitOS64bit OS

            //32bitCPUAddressWidth = 32N/A

            //64bitCPUAddressWidth = 32AddressWidth = 64

            textBox1.Text =Judgment64or32System().ToString();

       }

       /// <summary>

       /// 判斷當(dāng)前系統(tǒng)是32位的還是64

       /// </summary>

       /// <returns></returns>

       public staticstring Judgment64or32System()

       {

            try

            {

                stringaddressWidth = String.Empty;

                ConnectionOptionsmConnOption = new ConnectionOptions();

                ManagementScopemMs = new ManagementScope("\\\\localhost", mConnOption);

                ObjectQuerymQuery = new ObjectQuery("select AddressWidth from Win32_Processor");

                ManagementObjectSearchermSearcher = new ManagementObjectSearcher(mMs,mQuery);

                ManagementObjectCollectionmObjectCollection = mSearcher.Get();

                foreach(ManagementObject mObject in mObjectCollection)

                {

                    addressWidth = mObject["AddressWidth"].ToString();

                }

                returnaddressWidth;//返回值

            }

            catch(Exception ex)

            {

                Console.WriteLine(ex.Message.ToString());

                returnString.Empty;

            }

       }

   }

}

微信打賞, 微信掃一掃

支付寶打賞, 支付寶掃一掃

如果文章對您有幫助,歡迎給作者打賞

作者最新文章
開發(fā)過程中解決360兼容模式瀏覽器的方法
云南象群向西南方向遷移,云南離群獨(dú)象距離象群約12公里
吉林做網(wǎng)站最低價(jià)格,吉林企業(yè)網(wǎng)站建設(shè)價(jià)格低至500元起
守象人直擊云南象群最新動(dòng)向
網(wǎng)站影響百度蜘蛛抓取量的因素有哪些?為什么我的網(wǎng)站Baidu蜘蛛來的次數(shù)少?
企業(yè)名片
在線客服