Link to home
Start Free TrialLog in
Avatar of bogieman_
bogieman_

asked on

Get EXE name

If I know the handle to a window, how can I get the app filename?
Avatar of ckaneta
ckaneta

ExtractFileName(Application.EXEname)
will return the exename(full path, I think) of your program
if you need exename of any program, well
not sure on that one
Avatar of bogieman_

ASKER

This question has a deletion request Pending
I noticed you have two questions up of the same question.... if i give you this code, the other 50 points will have to go to Barry, He answered my question which whas this very one.....

And you Answer is....


function GetWindowExeName(Handle: THandle): String;
 var
PE: TProcessEntry32;
 Snap: THandle;
ProcessId: cardinal;
begin
 GetWindowThreadProcessId(Handle,@ProcessId);
 Snap:= CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if Snap <> 0 then begin
 if Process32First(Snap, PE) then
  if PE.th32ProcessID = ProcessId then
  Result:= String(PE.szExeFile)
   else while Process32Next(Snap, PE) do
 if PE.th32ProcessID = ProcessId then begin
  Result:= String(PE.szExeFile);
   break;
    end;
    CloseHandle(Snap);
   end;
 end;

This question no longer is pending deletion
Stop this Deletion Now!!!
ASKER CERTIFIED SOLUTION
Avatar of deeptesla
deeptesla

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial