本文介绍了在 C# 中,如何以编程方式知道操作系统是 x64 还是 x86的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 C# 中,我如何以编程方式知道操作系统是 x64 还是 x86
In C#, how can I know programmatically if the Operating system is x64 or x86
我在网上找到了这个API方法,但是没有用
I found this API method on the internet, but it doesn't work
[DllImport("kernel32.dll")] public static extern bool IsWow64Process(System.IntPtr hProcess, out bool lpSystemInfo); public static bool IsWow64Process1 { get { bool retVal = false; IsWow64Process(System.Diagnostics.Process.GetCurrentProcess().Handle, out retVal); return retVal; } }提前致谢.
推荐答案在 .NET 4.0 中,您可以使用新的 Environment.Is64BitOperatingSystem 属性.
In .NET 4.0 you can use the new Environment.Is64BitOperatingSystem property.
这就是它被阻碍的方式
public static bool Is64BitOperatingSystem { [SecuritySafeCritical] get { bool flag; return ((Win32Native.DoesWin32MethodExist("kernel32.dll", "IsWow64Process") && Win32Native.IsWow64Process(Win32Native.GetCurrentProcess(), out flag)) && flag); } }使用反射器或类似物来查看它是如何工作的.
Use reflector or similar to see exactly how it works.
更多推荐
在 C# 中,如何以编程方式知道操作系统是 x64 还是 x86
发布评论