我正在编写一个实用程序,它应该获取当前的CPU负载。目前它正在工作并在我的本地化中使用\Processor(_Total)\%processtime。对于多语言支持,我通过PdhLookupPerfNameByIndex从注册表中获取计数器名称。现在代码看起来像PdhLookupPerfNameByIndex(NULL,6,processorTime,&cbPathSize);PdhLookupPerfNameByIndex(NULL,238,processor,&cbPathSize);PDH_COUNTER_PATH_ELEMENTSelements={NULL,processor
我的代码:#include#include#include#pragmacomment(lib,"pdh.lib")voidmain(){PDH_STATUSStatus;HQUERYQuery=NULL;HCOUNTERCounter;WCHARbuffer[PDH_MAX_COUNTER_PATH];PdhOpenQuery(NULL,NULL,&Query);wcscpy(buffer,L"\\NTO-PROG\Thread(_Total/_Total)\ContextSwitches/sec");Status=PdhAddEnglishCounter(Query,buffer,