Einzelnen Beitrag anzeigen

helen

Registriert seit: 8. Mai 2004
42 Beiträge
 
#5

Re: An die Daten von PNotifyIconData herankommen

  Alt 18. Mai 2004, 11:59
Hallo,

wie kann ich denn den Zeiger auf die Callback-Funktion an die DLL übermitteln?

Das installieren des Hooks funktioniert so:
Code:
procedure TForm1.Button1Click(Sender: TObject);
begin
  InjectLibrary(ALL_SESSIONS or SYSTEM_PROCESSES, 'TBNAhook.dll');
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  UninjectLibrary(ALL_SESSIONS or SYSTEM_PROCESSES, 'TBNAhook.dll');
end;
der Hook selbst sieht so aus:
Code:
library TBNAhook;

uses
  Windows,
  madRemote,
  madCodeHook,
  madStrings,
  ShellAPI,
  dialogs;

var Shell_NotifyIcon : function (dwMessage: DWORD; lpData: PNotifyIconData) : bool; stdcall;
var Shell_NotifyIconA : function (dwMessage: DWORD; lpData: PNotifyIconData) : bool; stdcall;
var Shell_NotifyIconW : function (dwMessage: DWORD; lpData: PNotifyIconData) : bool; stdcall;


function MY_NotifyIcon (dwMessage: DWORD; lpData: PNotifyIconData): BOOL; stdcall;
begin
  ShowMessage (lpData.szTip);
  //Form1.AddIcon (dwMessage, @lpData);


  result := true;
end;

function MY_NotifyIconA (dwMessage: DWORD; lpData: PNotifyIconData): BOOL; stdcall;
begin
  ShowMessage (lpData.szTip);
  //Form1.AddIcon (dwMessage, @lpData);

  result := true;
end;

function MY_NotifyIconW (dwMessage: DWORD; lpData: PNotifyIconData): BOOL; stdcall;
begin
  ShowMessage (lpData.szTip);
  //Form1.AddIcon (dwMessage, @lpData);

  result := true;
end;

begin
  HookAPI('shell32.dll', 'Shell_NotifyIcon', @MY_NotifyIcon, @Shell_NotifyIcon);
  HookAPI('shell32.dll', 'Shell_NotifyIconA', @MY_NotifyIconA, @Shell_NotifyIconA);
  HookAPI('shell32.dll', 'Shell_NotifyIconW', @MY_NotifyIconW, @Shell_NotifyIconW);
end.
Ich habe nun versucht, das Icon aus PNotifyIconData mit
Code:
tmp := TIcon.Create;
tmp.Assign (lpData.hIcon);

ImageIndex := ImageList1.AddIcon (tmp);
in eine ImageList einzufügen, aber das läuft nicht...
  Mit Zitat antworten Zitat