英文:
Getting ProcessorInformation from CallNtPowerInformation()
问题
以前,我可以在Windows 10中获取当前的CPU核心频率,使用以下调用:
const NTSTATUS gotinfo = CallNtPowerInformation
(
ProcessorInformation,
NULL,
0,
pinf,
sizeof(pinf)
);
assert(gotinfo != ERROR_INSUFFICIENT_BUFFER);
assert(gotinfo != ERROR_ACCESS_DENIED);
assert(gotinfo == ERROR_SUCCESS);
但是当我今天尝试时,无论是Max还是Cur freq,我的i5 12600k所有核心都返回3700MHz。这是不正确的。该函数返回SUCCESS状态,但产生了不正确的结果。
发生了什么?为什么CallNtPowerInformation停止工作?
注意:Microsoft忘记包括PROCESSOR_POWER_INFORMATION的结构定义,并告诉你自己定义它。他们声称它会在新版本的WINNT.H中修复,但从未修复。
英文:
Formerly, I was able to get the current cpu core frequencies in Windows 10, using this call:
const NTSTATUS gotinfo = CallNtPowerInformation
(
ProcessorInformation,
NULL,
0,
pinf,
sizeof(pinf)
);
assert(gotinfo != ERROR_INSUFFICIENT_BUFFER);
assert(gotinfo != ERROR_ACCESS_DENIED);
assert(gotinfo == ERROR_SUCCESS);
But when I try that today, I always see 3700Mhz returned for both Max and Cur freq on my core i5 12600k, for all cores. This is incorrect. The function returns SUCCESS status, but yields incorrect results.
What happened here? Why did CallNtPowerInformation stop working?
NOTE: Microsoft forgot to include the struct definition for PROCESSOR_POWER_INFORMATION, and tells you do define it yourself. They claimed it would be fixed in new versions of WINNT.H but it never was.
答案1
得分: 3
Microsoft已经悄悄从API中移除了这个功能。
https://github.com/microsoft/Windows-Dev-Performance/issues/100
英文:
Microsoft has silently removed the functionality from the API.
https://github.com/microsoft/Windows-Dev-Performance/issues/100
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论