FZ95
FZ95

Reputation: 107

Get list of process

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

Answers (1)

Remy Lebeau
Remy Lebeau

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():

Enumerating All Processes

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

Related Questions