PdhAddEnglishCounter/PdhAddCounter 添加cpu计数器返回-1073738824 C000 0BB8

获取cpu负载时 使用pdhaddenglishcounter 返回-1073738824  C000 0BB8  

PDH_CSTATUS_NO_OBJECT 

 

auto state = PdhOpenQuery(NULL, NULL, &cpuQuery);
            if (state != ERROR_SUCCESS) {
                DLOG(ERROR) << "PdhOpenQuery Failed:" << state << std::endl;
                return 0;
            }
            state = PdhAddCounter(cpuQuery, "\\Processor(_Total)\\% Processor Time", NULL, &cpuTotal);
            if (state != ERROR_SUCCESS)
            {
                DLOG(ERROR) << "PdhAddEnglishCounter Failed" << PdhAddEnglishCounter(cpuQuery, "\\Processor(_Total)\\% Processor Time", NULL, &cpuTotal) << std::endl;
                return 0;
            }

解决方法:

重置性能计数

Lodctr /r

 

参考:

https://helgeklein.com/blog/how-to-easily-monitor-system-performance-with-the-new-diskled-1-1/

也可能是:

计算机\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PerfProc\Performance\Disable Performance Counters  设置成了 1

 

上一篇:浏览器性能检测——Performance、Lighthouse


下一篇:SAP OData服务性能测量的几种工具和手段