Registriert seit: 11. Nov 2003
Ort: Oldenburg
1.446 Beiträge
Delphi 10.2 Tokyo Enterprise
|
Re: DLL läst sich nicht entladen
15. Jun 2005, 10:01
Das klappt immer noch nicht.
Hat den keiner eine idee
hier nochmal den Code
Das Module
Delphi-Quellcode:
unit MPlugin;
interface
Uses FastShareMem, Forms, DB, Controls; //, mySQLDbTables, uStringArray;
Const
FVersion = ' 1.0';
type
TKomm = Record
var1,var2,var3,var4 : Variant;
von : Longint;
End;
TSysVars = Record
//Pfade
ProgPath : String;
TMPPath : String;
WinPath : String;
//SysVars
Aktrechner : String; //Echter Name
PCName : String; //Int Name
//PrgVars
IDatum : TDate; {Internes Datum}
AktJahr : Word;
AktMonat : Byte;
AktVer : String;
Firmenname1 : String;
Firmenname2 : String;
Firmenstrasse : String;
Firmenort : String;
AktWaehrung : String;
//Usermanagment
//OptList : THashStringArray;
AktUser : Longint;
End;
TONLPlugin = Class
private
{ Private-Deklarationen }
{FHostApp: TApplication;
FHostDB: TmySQLDataBase;
FSysVars: TSysVars;
FKomm: TKomm; }
{procedure SetSysVars(const Value: TSysVars);
procedure SetKomm(const Value: TKomm);
procedure SetHostApp(const Value: TApplication);
procedure SetHostDB(const Value: TmySQLDataBase); }
public
{ Public-Deklarationen }
{Property HostApp : TApplication read FHostApp write SetHostApp;
Property HostDB : TmySQLDataBase read FHostDB write SetHostDB;
Property SysVars : TSysVars read FSysVars write SetSysVars;
Property Komm : TKomm read FKomm write SetKomm; }
Constructor Create;
Destructor Destroy; override;
Function GetVersion : String;
//Starts
Procedure StartDay;
Procedure StartMonth;
Procedure StartYear;
Procedure UPDTabs;
End;
TLoadPlugin = Function : TONLPlugin; stdcall;
TUnloadPlugin = Procedure stdcall;
implementation
{ TONLPlugin }
constructor TONLPlugin.Create;
begin
inherited;
end;
destructor TONLPlugin.Destroy;
begin
inherited;
end;
function TONLPlugin.GetVersion : String;
begin
Result:=FVersion;
end;
{procedure TONLPlugin.SetHostApp(const Value: TApplication);
begin
FHostApp := Value;
end;
procedure TONLPlugin.SetHostDB(const Value: TmySQLDataBase);
begin
FHostDB := Value;
end;
procedure TONLPlugin.SetKomm(const Value: TKomm);
begin
FKomm := Value;
end;
procedure TONLPlugin.SetSysVars(const Value: TSysVars);
begin
FSysVars := Value;
end; }
procedure TONLPlugin.StartDay;
begin
//
end;
procedure TONLPlugin.StartMonth;
begin
//
end;
procedure TONLPlugin.StartYear;
begin
//
end;
procedure TONLPlugin.UPDTabs;
begin
//
end;
end.
Die DLL
Delphi-Quellcode:
library testplugin;
uses
SysUtils,
Classes,
FastShareMem,
MPlugin in '..\share\MPlugin.pas',
Forms;
{$R *.res}
Var
Plugin : TONLPlugin;
Function LoadPlugin : TONLPlugin; stdcall;
Begin
Plugin:=TONLPlugin.Create;
Result:=Plugin;
End;
Procedure UnloadPlugin; stdcall;
Begin
FreeAndNil(Plugin);
End;
Exports
LoadPlugin,
UnloadPlugin;
begin
end.
Der Loader
Delphi-Quellcode:
unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, MPlugin, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
DLLHandle : THandle;
Plugin : TONLPlugin;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
Var
LoadPlugin : TLoadPlugin;
begin
DLLHandle:=LoadLibrary(' dlls\testplugin.dll');
If DLLHandle<>32 then
Begin
LoadPlugin:=GetProcAddress(DLLHandle,' LoadPlugin');
Try
If Assigned(LoadPlugin) then
Plugin:=LoadPlugin;
except
FreeLibrary(DLlHandle);
End;
End;
end;
procedure TForm1.Button2Click(Sender: TObject);
Var
UnloadPlugin : TUnloadPlugin;
begin
If DLLHandle<>32 then
Begin
UnLoadPlugin:=GetProcAddress(DLLHandle,' UnloadPlugin');
Try
If Assigned(UnloadPlugin) then
UnloadPlugin;
except
End;
FreeLibrary(DLLHandle);
End;
end;
end.
Frank Tux sein Lieblingsquellcode
While anzfische<TuxSatt do begin
Fisch:=TFisch.Create; Tux.EssenFisch(Fisch); Fisch.Free;inc(anzfische); end;
|
|
Zitat
|