1

I'm trying to get CPU usage data with WMI. For this purpose I'm using the Win32_PerfRawData_PerfProc_Process class. When I run below code, I do not get any result.

ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2","SELECT * FROM Win32_PerfRawData_PerfProc_Process");
var data = searcher.Get();

Until here there is no any error, if I try to use data object, app waiting until I close it.

I made some research, but found nothing useful.

NOTE: Other WMI class queries work fine. And I need to use WMI (not performance counters).

Michel de Ruiter
  • 7,131
  • 5
  • 49
  • 74
S Topkaya
  • 51
  • 3

1 Answers1

0

Please take a look at registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\PerfProc\Performance and here the value of "Disable Performance Counters". It should be set to "0" for this Class to work.