• C#判断操作系统的位数


          在.net 4.5中,判断操作系统不用再写方法去判断了,有直接可以利用的属性了哦,如下所示:

    Environment.Is64BitProcess 属性

    .NET Framework 4.5       
     

    确定当前进程是否为 64 位进程。

     

        当然如果是用的.net 4.5以前的童鞋也不必担心,同样也可以用以下的方法来实现判断系统位数。

        private string Distinguish64or32System()
            {
                try
                {
                    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 mObject in mObjectCollection)
                    {
                        addressWidth = mObject["AddressWidth"].ToString();
                    }
                    return addressWidth;
                }
                catch (Exception ex)
                {
                  
                    return String.Empty;
                }
            }

  • 相关阅读:
    Salesforce的数据权限机制
    Java并发编程:Java内存模型和volatile
    Java并发编程:synchronized和锁优化
    权限控制和OAuth
    MySQL explain详解
    ConcurrentHashMap源码阅读
    HashMap源码阅读
    领域驱动设计的基础知识总结
    Chris Richardson微服务翻译:重构单体服务为微服务
    Chris Richardson微服务翻译:微服务部署
  • 原文地址:https://www.cnblogs.com/kevinGao/p/2990236.html
Copyright © 2020-2023  润新知