How to get the task name (exe file name) by a HWND?

  • Thread starter Thread starter Holger Kasten
  • Start date Start date
Hi Holger,

I don't know of any managed solution.
You can try PInvoke and call GetWindowModuleFileName API
 
Hi I tried to include it the follwoing way:

[DllImport("user32.dll")] public static extern
int GetWindowModuleFileName(IntPtr hWnd, System.Text.StringBuilder title,
int size);
and to call it:

System.Text.StringBuilder title = new System.Text.StringBuilder(256);
HK.WIN32API.User32.GetWindowModuleFileName(hwnd, title, 256);

Unfortunately title is an empty string all the time, besides I do this for a
window handle of my own app.

Any idea why?

Best regards,

Holger
 
Back
Top