AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

AV bei MausHook

Ein Thema von perle · begonnen am 2. Feb 2005 · letzter Beitrag vom 1. Jul 2005
Antwort Antwort
perle

Registriert seit: 8. Apr 2004
183 Beiträge
 
Delphi 7 Enterprise
 
#1

AV bei MausHook

  Alt 2. Feb 2005, 13:12
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:
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.
ist das überhaupt bis hier hin richtig?
Naja, jedenfalls rufe ich die Installfunktion dann im Hauptprogramm mit
if InstallHook(handle) then showmessage('installiert'); auf, das wird auch ausgeführt, die message wird ausgegeben, und schwupps , gibts ne Zugriffsverletzung. Weiss jemand warum das so ist?
  Mit Zitat antworten Zitat
Olli
(Gast)

n/a Beiträge
 
#2

Re: AV bei MausHook

  Alt 1. Jul 2005, 13:19
Ich würde dir erstmal empfehlen die ganzen Units aus USES zu entfernen (außer Windows und Messages). Teste dann nochmal.
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:56 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