[DLL] für mIRC: Typisch FPC?

Für Fragen zur Programmiersprache auf welcher Lazarus aufbaut
Antworten
Quit
Beiträge: 65
Registriert: So 5. Nov 2006, 18:58
OS, Lazarus, FPC: Winux (L 0.9.xy FPC 2.2.z)
CPU-Target: xxBit
Wohnort: Luzern

[DLL] für mIRC: Typisch FPC?

Beitrag von Quit »

Hallo... Ich habe ein problem, ich habe eine DLL gebaut, wie auf http://mirc.stealth.net/tutorials/mirc_dll_delphi.html" onclick="window.open(this.href);return false; beschrieben


Code:

Code: Alles auswählen

library mirc_dll;
{$mode delphi}
{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. }
 
uses
  SysUtils,
  Windows,
  Classes;
 
type
  TLoadInfo = packed record
    mVersion : DWORD;
    mHwnd    : HWND;
    mKeep    : Boolean;
  end;
  PLoadInfo = ^TLoadInfo;
 
//{$R *.RES}
 
(*
  This function is the first function being called when mIRC loads the dll.
*)
procedure LoadDll(LoadInfo: PLoadInfo); stdcall; export;
begin
  LoadInfo.mKeep := TRUE; // Tells mIRC to keep our DLL loaded
end;
(*
  This is the closing function of the DLL
    - It is either called when you close your DLL manually,
      or after ten minutes of no calls to the DLL.
*)
procedure UnloadDll(mTimeOut: integer); stdcall; export;
begin
  case mTimeOut of
    0: messagebox(0, 'Unloading mIRC DLL...', 'You are manually closing your DLL.', MB_OK);
    1: messagebox(0, 'Unloading mIRC DLL...', 'Your DLL has timedout after 10 minutes.', MB_OK);
  end;
end;
 
function ETA( mWnd: hWnd; aWnd: hWnd; Data: PChar; Parms: PChar;
Show: Boolean; NoPause: Boolean ): Integer; export; stdcall;
begin
  strcopy(data, 'The search for E.T. will never end!');
  result := 3;
end;
 
function ETB( mWnd: hWnd; aWnd: hWnd; Data: PChar; Parms: PChar;
Show: Boolean; NoPause: Boolean ): Integer; export; stdcall;
begin
  strcopy(data, '/echo The search for E.T. will never end!');
  strcopy(parms, '-a');
  result := 2;
end;
 
function MsgBox( mWnd: hWnd; aWnd: hWnd; Data: PChar; Parms: PChar;
Show: Boolean; NoPause: Boolean ): Integer; export; stdcall;
begin
  if NOT NoPause then
    MessageBox(mWnd, data, 'mIRC', MB_OK);
  result := 0;
end;
 
exports
  LoadDll,
  UnloadDll,
  ETA,
  ETB,
  MsgBox;
 
begin
end.
Ist mein Code irgendwie falsch oder habe ich etwas nicht angepasst, was FPC anderst macht? Das Problem ist, mIRC sieht, dass die DLL da ist, kann sie aber nicht öffnen.
Danke im Vorraus..

schnullerbacke
Beiträge: 1187
Registriert: Mi 13. Dez 2006, 10:58
OS, Lazarus, FPC: Winux (L 1.2.xy FPC 2.6.z)
CPU-Target: AMD A4-6400 APU
Wohnort: Hamburg

Beitrag von schnullerbacke »

Die Dinger heißen doch "dynamic link library" in LINÜX "shared object",

so wie du das gemacht hast wird die mIRC fest geladen. Dann mußt du aber auch deren Prozeduren und Funktionen als const beschreiben sonst wird das mit aufrufen nix.

Wenn sie denn dynamisch geladen werden soll brauchst du nen passenden Loader, ich find nur gerade meine Unit zu dem Thema nicht.
Humor ist der Knopf, der verhindert, daß uns der Kragen platzt.

(Ringelnatz)

Antworten