当前位置: 移动技术网 > IT编程>开发语言>c# > c#判断操作系统位数的示例分享

c#判断操作系统位数的示例分享

2019年07月18日  | 移动技术网IT编程  | 我要评论
在.net 4.5中,判断操作系统不用再写方法去判断了,有直接可以利用的属性了哦,如下所示:environment.is64bitprocess 属性.net framew

在.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;
}
}

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网