ARM64如何获取CPU品牌信息? [英] How to get CPU brand information in ARM64?

查看:32
本文介绍了ARM64如何获取CPU品牌信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Windows X86 中,CPU 品牌可以通过 cpuid 内在函数查询.下面是代码示例:

In Windows X86, the CPU brand can be queried with cpuid intrinsic function. Here is a sample of the code:

#include <stdio.h>
#include <intrin.h>

int main(void)
{
    int cpubrand[4 * 3];

    __cpuid(&cpubrand[0], 0x80000002);
    __cpuid(&cpubrand[4], 0x80000003);
    __cpuid(&cpubrand[8], 0x80000004);

    char str[48];
    memset(str, 0, sizeof str);
    memcpy(str, cpubrand, sizeof cpubrand);
    printf("%s\n", str);
}

Windows ARM64 中有什么替代方案?

What is the alternative of this in Windows ARM64?

推荐答案

虽然可能不是您正在寻找的答案(即直接询问 CPU),但您可以获取ProcessorNameString"使用如下代码从 Windows 注册表中获取值:

Although probably not the answer you're looking for (i.e. directly interrogating the CPU), you can fetch the "ProcessorNameString" value from the Windows Registry using code like the following:

#define BUFSIZ 64 // For easy adjustment of limits, if required

char answer[BUFSIZ] = "Error Reading CPU Name from Registry!", inBuffer[BUFSIZ] = "";
const char *csName = "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0";
HKEY hKey;  DWORD gotType, gotSize = BUFSIZ;
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, csName, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
    if (!RegQueryValueExA(hKey, "ProcessorNameString", nullptr, &gotType, (PBYTE)(inBuffer), &gotSize)) {
        if ((gotType == REG_SZ) && strlen(inBuffer)) strcpy(answer, inBuffer);
    }
    RegCloseKey(hKey);
}

这将(或应该)为您提供 Windows 系统看到的处理器名称"!我无法访问 ARM64 系统,因此无法对其进行正确测试,但是,在我的 x64 系统上,我得到以下(正确)字符串:Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz(正是,通过使用 __cpuid() 调用返回品牌字符串").

This will (or should) give you the processor's 'name' that the Windows system sees! I don't have access to an ARM64 system, so I can't properly test it but, on my x64 system, I get the following (correct) string: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz (which is exactly that returned by using __cpuid() calls to get the "Brand String").

但是,像您一样,我很想知道一种直接的方法 - 即,Windows O/S 如何在 ARM64 上获取此信息代码>系统?

However, like you, I would be very interested to know of a way to do this directly - i.e., how would the Windows O/S get this info on an ARM64 system?

这篇关于ARM64如何获取CPU品牌信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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