32位或64位计算机

3
我将使用以下代码来检查计算机是64位还是32位:

可能重复:
如何使用.NET检测Windows 64位平台?

我正在使用此代码来检查计算机是64位还是32位:

    public static string GetOSBit()
    {
        bool is64bit = Is64Bit();
        if (is64bit)
            return "64 bit";
        else
            return "32 bit";
    }

    [DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)]
    [return: MarshalAs(UnmanagedType.Bool)]
    public static extern bool IsWow64Process([In] IntPtr hProcess, [Out] out bool lpSystemInfo);

    public static bool Is64Bit()
    {
        bool retVal;
        IsWow64Process(Process.GetCurrentProcess().Handle, out retVal);
        return retVal;
    }

我有一台32位的电脑,对我来说它运行良好。它返回“32位”。然而,我的朋友也有一台32位的电脑,但安装了一个64位的虚拟机。上面的代码为她的虚拟机返回“32位”,尽管它是64位的。 我使用C#,.Net 2.0。


如API所示,这描述的是一个过程,而不是机器。 - sehe
2个回答

2

函数IsWow64Process用于判断指定的进程是否在WOW64模式下运行。当在64位操作系统下运行32位进程时,该函数返回true


-1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接