Re: GetWinFileName
- From: Geoffrey Summerhayes <sumrnot@xxxxxxxxx>
- Date: Tue, 6 May 2008 13:59:19 -0700 (PDT)
On May 6, 1:42 pm, battles <batt...@xxxxxxxxxxxxxx> wrote:
I have a dll that passes the handle of any programs that start on a
computer to my program. I am trying to get the function that I copied
from news below to give me the executable's name upon passing the
handle to it. The function, however, always passes back my own
program's executable name. The handle I pass to the function is not
mine. Can anyone see if I am doing something wrong?
type GetWinFileNameA = function(hWnd : HWND; FileName : PChar;
Length : Integer):Integer;stdcall;
function GetFileNameFromWindow(hWnd : HWND):string;
var
hModule : THandle;
GetWinFileNameAProc : GetWinFileNameA;
Buffer : array[0..255] of Char;
begin
hModule := LoadLibrary('USER32.DLL');
@GetWinFileNameAProc := GetProcAddress(hModule,
'GetWindowModuleFileNameA');
GetWinFileNameAProc(hWnd, Buffer, 255);
Result := Buffer;
end;
Note: I don't know if this would be a problem, but I tried to use
'hModule : HMODULE' but HMODULE is causing an error.
Using outdated code, it should work fine on Win98.
Handles aren't shared between all processes after that.
Search MSDN for PSAPI
---
Geoff
.
- Follow-Ups:
- Re: GetWinFileName
- From: battles
- Re: GetWinFileName
- References:
- GetWinFileName
- From: battles
- GetWinFileName
- Prev by Date: Re: Display _FileTime
- Next by Date: Re: GetWinFileName
- Previous by thread: GetWinFileName
- Next by thread: Re: GetWinFileName
- Index(es):
Relevant Pages
|