Reputation: 107
I need to get the list of process with their PID. I know how to get the PID by its handle and viceversa, but the problem is that I'm not the one who create the process, so I don't have the handle nor the PID. I didn't find exactly information on how to do it on Internet.
Is there some function that returns the list of process with their PID?
I mean something like get all the PIDs of 'chrome.exe', for example.
Both VCL and Firemonkey solutions are appreciated.
Upvotes: 1
Views: 1449
Reputation: 595422
This is very platform-specific, and as such there is nothing in FireMonkey or VCL to help you with it. You have to use platform APIs directly.
For instance, on Windows you can use CreateToolhelp32Snapshot(), Process32First() and Process32Next():
Taking a Snapshot and Viewing Processes
Or you can use EnumProcesses():
Either approach will getyou a list of filenames and PIDs, then you can filter the list for the filename(s) you are interested in.
Upvotes: 6