Thema: Delphi DLL Auslesen

Einzelnen Beitrag anzeigen

Benutzerbild von XXcD
XXcD

Registriert seit: 19. Sep 2006
581 Beiträge
 
Delphi 2007 Professional
 
#5

Re: DLL Auslesen

  Alt 13. Jun 2009, 15:02
Ich habe jetzt mal das gemacht was da in dem Kommentar steht:

testdll.dll
Delphi-Quellcode:
library testdll;

uses
  SysUtils,
  Classes,
  Forms;

  type
  TInformationen = class
    Version : ShortString;
    Name : ShortString;
    Description: ShortString;
    Settings: boolean;
    Visible: boolean;
  end;

{$R *.res}

function DLLInformationen: TInformationen; stdcall;
var
Informationen: TInformationen;
begin
Informationen:= TInformationen.Create;
Informationen.Version:='1.0';
Informationen.Name:='First Modul';
Informationen.Description:='Kleine beschreibung';
Informationen.Settings:=true;
Informationen.Visible:=true;
Result:=Informationen;
end;

exports DLLInformationen;

begin
end.
Auslesen:
Delphi-Quellcode:

interface

uses
windows, SysUtils;

  type
  TInformationen = class
    Version : ShortString;
    Name : ShortString;
    Description: ShortString;
    Settings: boolean;
    Visible: boolean;
  end;

type
  TGetInformations = function: TInformationen; stdcall;
  function ModulInformationen: TInformationen;

implementation

function ModulInformationen: TInformationen;
var GetInformations: TGetInformations;
    Handle: THandle;
begin
  Handle:=LoadLibrary(PChar(ExtractFilePath(ParamStr(0))+'\Module\testdll.dll'));
  if Handle <> 0 then begin
    @GetInformations := GetProcAddress(Handle, 'DLLInformationen');
    if @GetInformations <> nil then begin
      result := GetInformations;
    end;
    FreeLibrary(Handle);
  end;
end;

end.

Der Aufruf
Delphi-Quellcode:
Informationen:=ModulInformationen;
Showmessage(Informationen.Version+' | '+Informationen.Name);
Der Fehler bleibt aber der gleiche.

Wie kann ich denn Interfaces nutzen?
  Mit Zitat antworten Zitat