Einzelnen Beitrag anzeigen

Benutzerbild von RWarnecke
RWarnecke

Registriert seit: 31. Dez 2004
Ort: Stuttgart
4.408 Beiträge
 
Delphi XE8 Enterprise
 
#8

Re: DLL dynamisch laden

  Alt 13. Feb 2009, 12:56
So rufe ich meine AboutBox-Form auf, die in einer DLL ist :
Delphi-Quellcode:
type
  TFormDLLBox = procedure(appHandle: THandle); stdcall;

procedure TMainForm.Act_AboutBoxExecute(Sender: TObject);
var
  hDLL: THandle;
  AboutBoxWindow: TFormDLLBox;
begin
  hDLL := LoadLibrary(PChar(ExtractFilePath(ParamStr(0)) + HLPBOXES));
  if hDLL <> 0 then
  begin
    try
      AboutBoxWindow := GetProcAddress(hDLL, 'AboutBox');
      AboutBoxWindow(Application.Handle);
    finally
      FreeLibrary(hDLL);
    end;
  end
  else
    Application.MessageBox(PChar('Die Datei "' + HLPBOXES + '" konnte nicht gefunden werden.' + #13#10+
      'Bitte überprüfen Sie Ihr Programmverzeichnis'), 'Hinweis', MB_OK);
end;
Das ganze sollte auch auf eine normale Funktion oder Procedure Deiner DLL anwendbar sein.
Rolf Warnecke
App4Mission
  Mit Zitat antworten Zitat