Mega Code Archive

 
Categories / Delphi / System
 

Application path & name from windows handle

Title: Application path & name from windows handle. Question: How do I retrieve a filename from a windows handle? Answer: 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)));