问题描述
System.Environment中是否有可以告诉我程序是否在64位操作系统上运行?b $ b?我现在想的是检查IntPtr的大小
,如果它是4那么它是32位,但如果它是8那么它是64位。
谢谢,
Eric Renken
Is there something in System.Environment that can tell me if the program is
running on a 64bit OS? What I am thinking is right now is to check the size
of IntPtr and if it is 4 then it is 32bit, but if it is 8 then it is 64bit.
Thanks,
Eric Renken
推荐答案
无需乱搞IntPtr:
如果你在64位操作系统上运行,OSArchitecture属性将返回
" 64-bit"作为一个字符串...
-
No need to mess around with IntPtr:
http://msdn2.microsoft.com/En-US/library/aa394239.aspx
If you''re running on a 64-bit OS, the OSArchitecture property will return
"64-bit" as a string...
--
http://www.markrae.net
检查IntPtr.Size到底有什么问题?我不能想到
更直接的事情。如果你想要,那么称之为过早优化,但我也打赌它比任何涉及WMI的
要快得多。
Mattias
-
Mattias Sj?gren [C#MVP] mattias @ mvps.org
|
请回复到新闻组。
What exactly is messy with checking IntPtr.Size? I can''t think of
anything more straight forward. Call it premature optimization if you
want, but I also bet that it''s significantly faster than anything
involving WMI.
Mattias
--
Mattias Sj?gren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
这篇关于在64位操作系统中检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!