AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

DLL Auslesen

Ein Thema von XXcD · begonnen am 13. Jun 2009 · letzter Beitrag vom 14. Jun 2009
 
Benutzerbild von XXcD
XXcD

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

DLL Auslesen

  Alt 13. Jun 2009, 15:42
Hallo,
ich schreibe momentan an einem Programm dass durch DLL Datein erweitert werden kann.
Die DLLs sollen kleine Module sein.

Meine DLL sieht folgendermaßen aus(testdll.dll):
Delphi-Quellcode:
library testdll;

uses
  SysUtils,
  Classes,
  Forms;

  type
  TInformationen = class
    FVersion : String;
    FName : String;
    FDescription: string;
  end;

{$R *.res}

function DLLInformationen: TInformationen; stdcall;
var
Informationen: TInformationen;
begin
Informationen:= TInformationen.Create;
Informationen.FVersion:='1.0';
Informationen.FName:='First Modul';
Informationen.FDescription:='Kleine beschreibung';
Result:=Informationen;
end;

exports DLLInformationen;

begin
end.

Und so die Unit zum Auslesen der DLL(Modul_functions.pas):
Delphi-Quellcode:
uses
windows, SysUtils;

  type
  TInformationen = class
    private
    FVersion : String;
    FName : String;
    FDescription: string;
    FSettings: boolean;
    FVisible: boolean;
    public
    property Version: string read FVersion;
    property Name: string read FName;
    property Description: string read FDescription;
    property Settings: boolean read FSettings;
    property Visible: boolean read FVisible;
  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.

Und so der Aufruf in dem Formular:
Delphi-Quellcode:
uses
Modul_functions;
...
var
Informationen: TInformationen;
begin
Informationen:=ModulInformationen;
Showmessage(Informationen.Version+' | '+Informationen.Name);
Ich bin jetzt seit Stunden am suchen aber ich finde den Fehler einfach nicht.
Ich habe das genauso gemacht wie bei Delphi Treff in den TuTs
  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 12:27 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz