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?
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.