Getting info abot processes

How do you get the name of a file which created a process that you have the PID of, or a window which you have the handle for?
I've tried

hInst = GetWindowLong(hWnd, GWL_HINSTANCE);
GetModuleFileName(hInst, text, 101);

where hInst is a HINSTANCE and hWnd is the handle of a window received through EnumWindows. This just gives me the path and name of MY app, not the app that hWnd belongs to.

Comments

  • Retrieve the process ID with GetWindowThreadProcessId, and call CreateToolhelp32Snapshot with the flag TH32CS_SNAPMODULE. Call Module32First to get information about the first module, which is always the one which was used to load the program.
  • Ok, thanks!

    /Valderman

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories