Home > C, Programming, Win32 API > Path of other process

Path of other process

A few days ago I try to find a way to get path of a specific process, well here is snipped  code do this work. you need Process ID to use with CreateToolhelp32Snapshot API and then get process path with Module32First API

 DWORD dwPID;	// PID of process
 MODULEENTRY32 module = {sizeof(MODULEENTRY32)};

 HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwPID);
 if ( Module32First(hSnap, &module) )
   MessageBox(hWnd, module.szExePath, "MsG", MB_OK);

 CloseHandle(hSnap);

it’s very simple, isn’t? :)

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.