1

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.

3
  • 1
    Surely you haven't done enough searching, I see questions on this subject every week or two. As for Firemonkey, which platforms do you want to support? The solution wouldn't be specific to VCL or FMX, but rather to the platforms you want to support. Commented Jun 10, 2015 at 17:35
  • 1
    msdn.microsoft.com/en-us/library/windows/desktop/… Commented Jun 10, 2015 at 17:40
  • @Jerry Yeah my bad. After reading the solution from Remy I noticed I was searching the wrong thing. Commented Jun 10, 2015 at 17:49

1 Answer 1

6

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.