Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要以编程方式知道(c/c++)当前正在运行的进程的即时 CPU 负载是多少。Win32 API 提供了许多低级 API,但我找不到一个能够为我提供正在运行的 c/c++ 程序的当前 CPU 负载的 API。
问题是:如何以编程方式知道当前进程正在使用多少百分比的 CPU 负载。
您可以以编程方式使用性能计数器。请参阅使用性能计数器和一些示例代码。
您应该能够使用 perfmon 通过 id 获取任何进程的 CPU 使用情况 - 只需查找进程 id 的使用情况。