![]() |
AV bei MausHook
Hallo zusammen, ich wollte einen Maushook schreiben, der eine Message an mein Programm schickt , wenn die Linke Maustaste gedrückt wurde (macht nicht viel Sinn, ist auch nur zu Testzwecken). Ich habe also folgendes zusammengebastelt :
Delphi-Quellcode:
ist das überhaupt bis hier hin richtig?
library hookdll;
uses madExcept, madLinkDisAsm, SysUtils, Dialogs, windows, messages, Classes; var HookHandle : Cardinal; ProgHwnd : Cardinal; {$R *.res} function mouseproc(ncode : Integer; wp : WPARAM; lp : LPARAM) : LRESULT ; stdcall; begin result := CallNextHookEx(HookHandle,ncode,wp,lp); if (nCode = HC_ACTION) and (wp = WM_LBUTTONDOWN) then begin cds.dwData := wp; cds.cbData := 0; cds.lpData := nil; SendMessage(ProgHwnd,WM_COPYDATA,LongInt(HookHandle),LongInt(@cds)); end; end; function InstallHook(aHandle : Cardinal) : BOOL; stdcall; begin ProgHwnd := aHandle; HookHandle := SetWindowsHookEx(WH_MOUSE,@mouseproc,HInstance,0); if HookHandle <> 0 then result := TRUE else result := FALSE; end; function UninstallHook : BOOL; stdcall; begin result := UnhookWindowsHookEx(HookHandle); end; exports InstallHook, UninstallHook; begin end. Naja, jedenfalls rufe ich die Installfunktion dann im Hauptprogramm mit
Delphi-Quellcode:
auf, das wird auch ausgeführt, die message wird ausgegeben, und schwupps , gibts ne Zugriffsverletzung. Weiss jemand warum das so ist?
if InstallHook(handle) then showmessage('installiert');
|
Re: AV bei MausHook
Ich würde dir erstmal empfehlen die ganzen Units aus USES zu entfernen (außer Windows und Messages). Teste dann nochmal.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:50 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz