日期:2014-05-17  浏览次数:20809 次

检测是否运行在64位WIN7系统上
如何用C#代码检测当前进程是运行在WIN7 64位系统上?
------解决方案--------------------
搜来的:
 
private int Detect3264()
        {
            ConnectionOptions oConn = new ConnectionOptions();
            ManagementScope oMs = new ManagementScope("\\\\localhost", oConn);
            ObjectQuery oQuery = new ObjectQuery("select AddressWidth from Win32_Processor");
            ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(oMs, oQuery);
            ManagementObjectCollection oReturnCollection = oSearcher.Get();
            string addressWidth = null;

            foreach (ManagementObject oReturn in oReturnCollection)
            {
                addressWidth = oReturn["AddressWidth"].ToString();
            }
            return Convert.ToInt32(addressWidth);
        }

 

最后别忘添加引用System.Management


------解决方案--------------------
c# 检测32/64系统 

2012-06-28 08:59 C# 如何判断系统是64位还是32位
------解决方案--------------------
最近在项目中需要检测系统是32位,还是64位的

找到一个非常简单的方法来检测。

结果在:win xp 32bit,win7 32bit,win7 64bit, server2008 64bit 测试通过。

string.Format("Your OS is {0}bit", IntPtr.Size * 8);