[求助]谁会用CallNtPowerInformation取cpu的主频?
[求助]谁会用CallNtPowerInformation取cpu的主频?
在网上查到资料,说这个函数可以取cpu的主频,我试了下,什么都取不到
以下是我的源码,我用dev-c++编译的,引用了libPowrprof.a:
#include <cstdlib>
#include <iostream>
#include <windows.h>
#ifndef _HEADERFILENAME_H_
#define _HEADERFILENAME_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <Powrprof.h>
#ifdef __cplusplus
}
#endif
#endif // _HEADERFILENAME_H_
#include <WinDef.h>
using namespace std;
typedef struct _PROCESSOR_POWER_INFORMATION {
ULONG Number;
ULONG MaxMhz;
ULONG CurrentMhz;
ULONG MhzLimit;
ULONG MaxIdleState;
ULONG CurrentIdleState;
} PROCESSOR_POWER_INFORMATION, *PPROCESSOR_POWER_INFORMATION;
int main(int argc, char *argv[])
{
NTSTATUS Processor_information;
PROCESSOR_POWER_INFORMATION p;
Processor_information=CallNtPowerInformation(ProcessorInformation, NULL, 0,&p, sizeof(p));
if (Processor_information==STATUS_SUCCESS){
printf("s \n");}
else
{printf("f \n");}
printf("Number: \n", p.Number);
printf("maxhz: \n", p.MaxMhz);
printf("CurrentMhz: \n", p.CurrentMhz);
printf("MhzLimit: \n", p.MhzLimit);
printf("MaxIdleState: \n", p.MaxIdleState);
printf("CurrentIdleState: \n", p.CurrentIdleState);
system("PAUSE");
return EXIT_SUCCESS;
}
在vs 2005里面也试了,引用了Powrprof.lib,编译无错误,也什么都取不到
#include "stdafx.h"
#include <windows.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <Powrprof.h>
#ifdef __cplusplus
}
#endif
#include <WinDef.h>
typedef struct _PROCESSOR_POWER_INFORMATION { ULONG Number; ULONG MaxMhz; ULONG CurrentMhz; ULONG MhzLimit; ULONG MaxIdleState; ULONG CurrentIdleState;
} PROCESSOR_POWER_INFORMATION, *PPROCESSOR_POWER_INFORMATION;
int _tmain(int argc, _TCHAR* argv[])
{
PROCESSOR_POWER_INFORMATION p;
CallNtPowerInformation(ProcessorInformation, NULL, 0,&p, sizeof(p));
printf("maxhz: \n", p.MaxMhz);
system("PAUSE");
return 0;
}
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课