Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Problem mit Messagehook (https://www.delphipraxis.net/43241-problem-mit-messagehook.html)

Lesco 31. Mär 2005 10:04


Problem mit Messagehook
 
Delphi-Quellcode:
var
  buf: Cardinal;
 
begin
  GetWindowThreadProcessId(trgtHandle, @buf);
 hHk := SetWindowsHookEx(WH_GETMESSAGE, @MessageHookProc, hInstance, buf);
dieser aufruf von setWindowsHookEx gibt immer 0 zurück. die processid wurde korrekt ermittelt und bei GetLastError wird eine Zugriffsverletzung in der user32.dll angezeigt

Mephistopheles 31. Mär 2005 10:30

Re: Problem mit Messagehook
 
Und dein Hook liegt in einer DLL? Also sowohl MessageHookProc() als auch obige Routine?

Ich weiß nicht, wie GetWindowThreadProcessId() bei dir deklariert ist, aber vielleicht ist ja folgendes etwas intuitiver für dich:
Delphi-Quellcode:
GetWindowThreadProcessId(hWnd: HWND; var dwProcessId: DWORD): DWORD; stdcall;
Hinten muß dann natürlich noch der DLL-Name ran.

Bitte stelle hier auch einmal den Prototypen deiner MessageHookProc() rein.

Lesco 31. Mär 2005 10:42

Re: Problem mit Messagehook
 
Delphi-Quellcode:
function MessageHookProc(nCode: Integer; wParam,lParam: Integer): LRESULT; stdcall;
und zu GetWindowThreadProcessId sagt msdn folgendes:
Zitat:

DWORD GetWindowThreadProcessId(

HWND hWnd,
LPDWORD lpdwProcessId
);

[out] Pointer to a variable that receives the process identifier. If this parameter is not NULL, GetWindowThreadProcessId copies the identifier of the process to the variable; otherwise, it does not.
deshalb hab ich die adresse von buf übergeben und die processid wird auch korrekt stimmt auch


Alle Zeitangaben in WEZ +1. Es ist jetzt 04:40 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz