最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
检查你的系统是32位还是64位的c#函数
时间:2022-06-25 08:10:14 编辑:袖梨 来源:一聚教程网
以下代码片段是C#检查系统是32位还是64位的,有需要的朋友可以直接拿去测试。
代码如下 | 复制代码 |
using System; using System.Collections.Generic; using System.Text; using System.Management; public class Check64or32System { /// /// 检查系统是32位还是64位 /// /// public static int Distinguish64or32System() { try { //得到AddressWidth值 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(); string retVal = string.Empty; foreach (ManagementObject mObject in mObjectCollection) { retVal = mObject["AddressWidth"].ToString(); } //根据值判断,不能直接返回得到的值, //32位返回"32",64位会因为CPU而有两个值,"N/A"或"64" if (retVal == "32") { return 32; } else { return 64; } } catch { return 0; } } } |
相关文章
- 星露谷物语星之果实怎么收集-星之果实全收集攻略 07-12
- 剑星艾米尔商店位置在哪里 位置分布一览 07-12
- 送礼物发朋友圈的文案 07-12
- 幻兽帕鲁霹雳犬在哪抓 帕鲁霹雳犬抓捕位置介绍 07-12
- 突破倒计时:顶尖交易员揭示以太坊的牛市布局 07-12
- 幻兽帕鲁严冬鹿值得抓取吗 帕鲁严冬鹿抓取建议分享 07-12