1

Possible Duplicate:
Windows API's which will show the running processes

all process id in process Hacker

How do I get the process ID of all the processes of the iexplorer.exe? getcurrentprocessid() is getting the parent process id when I inject my DLL in the iexplorer.exe process.

How can I do this?

Community
  • 1
  • 1
Rashmi A M
  • 242
  • 1
  • 5
  • 15
  • can you please elaborate the problem.......... – jiten Sep 24 '12 at 09:47
  • when IE is opened with multiple tabs it has multiple PID... when i Inject my DLL in multiple Process of IE, with GetCurrentProcessId() function i am getting the parent process PID, that is only one PID i wanna get all the PID of IE – Rashmi A M Sep 24 '12 at 09:52
  • Recurse over that process children. – m0skit0 Sep 24 '12 at 10:08

1 Answers1

3

The best way is to just enumerate all processes on the system, and pick the ones that are IE. There are a few simple ways to get information about all processes running on the system:

  1. EnumProcesses, from PSAPI. This is probably the simplest but doesn't give much info; you need to use other APIs to gather the info you need (OpenProcess / GetModuleFileNameEx).
  2. CreateToolhelp32Snapshot (then Process32First and Process32Next), from TlHelp32.h. Quite simple to use, and automatically gives you the EXE name so you can easily tell if it's iexplorer.exe.
  3. WMI, as @nogard already mentioned.
tenfour
  • 36,141
  • 15
  • 83
  • 142