检测,如果所述处理器是在32位操作系统64位 [英] Detect if the processor is 64-bit under 32 bit OS

查看:189
本文介绍了检测,如果所述处理器是在32位操作系统64位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常情况下,x86-64架构提供兼容x86的。 32位Windows(或其它操作系统)可以在一个的x86-64处理器上运行。 (纠正我,如果我错了)。

Normally, x86-64 architecture offers compatibility with x86. A 32-bit Windows (or other OS) can run on an x86-64 processor. (Correct me if I am wrong).

我想知道是否有可能(在C ++)的32位Windows知道,如果底层的处理器是64位的。例如,如果Windows 7 32位的酷睿i5运行,我们应该能够知道,处理器是64位(尽管Windows 7的32位运行)。

I would like to know if it is possible (in C++) for a 32-bit Windows to know that if underlying processor is 64-bit. For example, if Windows 7 32-bit running on Core i5, we should be able to know that processor is 64-bit (although Windows 7 32 bit is running).

您可能会质疑,即使处理器是64位和操作系统是32位,64位进程无法运行(纠正我,如果我错了)的要求。但该方案的目的是知道的处理器,而不是操作系统。 这个问题可能会出现与此类似,但它不会给任何淡淡的C ++程序。

You may question the requirement that even if processor is 64 bit and OS is 32 bit, 64 bit processes cannot run (Correct me if I am wrong). But the aim of the program to know the processor, not OS. This question may appear similar to this, but it does not give any hint of C++ program.

推荐答案

嗯,据我所知,你只能得到这个通过查看CPU的信息本身。我觉得应该是足够的(适用于x86和放大器; AMD64),检查CPU是否支持长模式

Well, as far as I am aware, you can only get this through looking at the CPU information itself. I think it should be enough (for x86 & amd64) to check whether the CPU supports long mode.

对于这一点,你可以使用 CPUID在x86 指令。由Windows岬您的文章中,我会带你使用Microsoft C ++编译器猜测。对于这一点,有一个 __ CPUID 内在。可悲的是,微软的页面说明结束于 PBE 标记,而流明标记在我cpuinfo中去三旗后。

For that, you could use the cpuid instruction on x86. By Windows-ness of your post, I'll take a guess you're using the Microsoft C++ compiler. For that, there's a __cpuid intrinsic. Sadly, the description on Microsoft's page ends at PBE flag, while lm flag in my cpuinfo goes three flags later.

看着 CPUID改装AMD处理器,即可获得 LM 信息类型= 0x80000001 ,其结果是在位的最后一个返回整数29 。在 CPUID修改为英特尔处理器的相同位指定 EM64T 标志相当于AFAIK。

Looking at CPUID Modifications for AMD Processors, you can get LM with InfoType = 0x80000001, with the result being at bit 29 of the last returned integer. In CPUID Modifications for Intel Processors the same bit specifies EM64T flag which is equivalent AFAIK.

在这两种情况下,你应该做的信息类型= 0x80000000的首先以获得最大的意义信息类型值。如果是小于 0x80000001 ,那么你不应该做上述检查,而是假设不支持长模式。

In both cases, you should be doing InfoType = 0x80000000 first to get maximum meaningful InfoType value. If it's less than 0x80000001, then you should not do the above check and instead assume long mode is not supported.

这篇关于检测,如果所述处理器是在32位操作系统64位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆