API - path do aplicativo

Top  Previous  Next

This function will return the executable name and path of an application specified by it's windows handle. 

 

function GetAppName(hwindow: HWND): string; 

var 

  h : HMODULE; 

begin 

  SetLength(Result, 100); 

  h:=GetClassLong(hwindow, GCL_HMODULE); 

  GetModuleFileName(h, PChar(Result), 100); 

end; 

 

 

eg.  ShowMessage(GetAppName(FindWindow('notepad.exe', nil)));