bogieman_
asked on
Get EXE name
If I know the handle to a window, how can I get the app filename?
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(H andle,@Pro cessId);
Snap:= CreateToolHelp32Snapshot(T H32CS_SNAP PROCESS, 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;
And you Answer is....
function GetWindowExeName(Handle: THandle): String;
var
PE: TProcessEntry32;
Snap: THandle;
ProcessId: cardinal;
begin
GetWindowThreadProcessId(H
Snap:= CreateToolHelp32Snapshot(T
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
will return the exename(full path, I think) of your program
if you need exename of any program, well
not sure on that one