简体   繁体   中英

How to get all running processes in Qt

I have two questions:

  1. Is there any API in Qt for getting all the processes that are running right now?
  2. Given the name of a process, can I check if there is such a process currently running?

Process APIs are notoriously platform-dependent. Qt provides just the bare minimum for spawning new processes with QProcess . Interacting with any processes on the system (that you didn't start) is out of its depth.

It's also beyond the reach of things like Boost.Process . Well, at least for now. Note their comment:

Boost.Process' long-term goal is to provide a portable abstraction layer over the operating system that allows the programmer to manage any running process, not only those spawned by it. Due to the complexity in offering such an interface, the library currently focuses on child process management alone.

I'm unaware of any good C++ library for cross-platform arbitrary process listing and management. You kind of have to just pick the platforms you want to support and call their APIs. (Or call out to an external utility of some kind that will give you back the info you need.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM