Re: GetWinFileName



On May 8, 4:40 pm, battles <batt...@xxxxxxxxxxxxxx> wrote:
  Thanks.  Just didn't need this -  GetModuleFileNameExA.
Here is what I was able to come up with:

uses PSAPI

function  GetWindowExeName(PassedHandle: THandle): String;
var StrngLen: Integer; ProcID: Cardinal; ProcHndl: THandle;
begin
  GetWindowThreadProcessID(PassedHandle, @ProcID);
  ProcHndl := OpenProcess(PROCESS_QUERY_INFORMATION or
PROCESS_VM_READ, FALSE, ProcID);
  SetLength(Result, 250);
  StrngLen := GetModuleFileNameEx(ProcHndl, 0, PChar(Result), 250);
  SetLength(Result, StrngLen);

Play nice, blah, blah, dire consequences, yadda, yadda, Oooooh!

CloseHandle(ProcHndl);

end;

---
Geoff
.



Relevant Pages