AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) hook -> variable von form1 in dll bestimmen
Thema durchsuchen
Ansicht
Themen-Optionen

hook -> variable von form1 in dll bestimmen

Ein Thema von denizli · begonnen am 27. Feb 2012 · letzter Beitrag vom 1. Mär 2012
 
denizli

Registriert seit: 26. Dez 2010
2 Beiträge
 
#1

hook -> variable von form1 in dll bestimmen

  Alt 27. Feb 2012, 20:45
Hallo,

wie kann ich von der DLL auf die Variable von Form1 zugreifen ?

Hier der Code:

DLL
Delphi-Quellcode:
library jtdll;

uses
    Windows, Dialogs, Messages;

var
    HookHandle: Cardinal=0;
    WindowHandle: Cardinal=0;

function KeyboardHookProc(nCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
begin
    Result:=CallNextHookEx(HookHandle, nCode, wParam, lParam);
    case nCode<0 of
        true: exit;
        false: begin
            if (wParam=VK_F5) then xyz:=1; // Hier die Zeile, die nicht funktioniert. Variable 'xyz' ist von Form1, die ich hier an der Stelle ändern möchte
        end;
    end;
end;

function InstallHook(Hwnd: Cardinal): Boolean; stdcall;
begin
    result:=false;
    if HookHandle=0 then begin
        HookHandle:=SetWindowsHookEx(WH_KEYBOARD, @KeyboardHookProc, HInstance, 0);
        WindowHandle:=Hwnd;
        Result:=true;
    end;
end;

function UninstallHook: Boolean; stdcall;
begin
    Result:=UnhookWindowsHookEx(HookHandle);
    HookHandle:=0;
end;

exports
    InstallHook,
    UninstallHook;
end.
Form1
Delphi-Quellcode:
var xyz: integer;

function InstallHook(AppHandle: HWND): Boolean; stdcall; external 'jtdll.dll';
function UninstallHook: Boolean; stdcall; external 'jtdll.dll';

procedure TForm1.FormCreate(Sender: TObject);
begin
    InstallHook(handle);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
    UninstallHook;
end;
LG

Geändert von denizli (27. Feb 2012 um 21:28 Uhr)
  Mit Zitat antworten Zitat
 


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 17:30 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