The most efficient and fundamental way to use cpu% and network bandwidth on Windows?

What is the most efficient and fundamental way to use cpu% and network bandwidth on a Windows platform?

Correct me if I am wrong ...

  • windows api // Win32? SDK? (c / c ++) #sorry, I have no idea ...
  • Windows Management Instrumentation (WMI),
    • Class Win32_PerfFormattedData_Tcpip_NetworkInterface BytesReceivedPerSec
    • Class Win32_PerfRawData_PerfOS_Processor PercentProcessorTime
  • System.Diagnostics PerformanceCounter
  • Performance Data Assistant (PDH), pdh.dll
  • PerformanceCounter (C # /. NET framework) or another nowaday method?
  • NtQuerySystemInformation in ntdll.dll

So, what is the best way to get these values, can I import windows.h and kernel32.dll in order to get both % cpu utilization and network interface speed ?

thanks

+6
source share
2 answers

In C ++, I would use PdhOpenQuery , PdhAddCounter , etc ... I don’t know for C #, but I think there is something available in .NET.

+1
source

What is the best way

Depends on the rest of the program. In .NET (noting the C # tag for a question), it's easy to access WMI and performance counters.

From the Win32 API, if you use COM, then WMI may be the easiest, since reading performance data requires significant template code (from any API you start with).

+1
source

Source: https://habr.com/ru/post/901494/


All Articles