Hi,
Ich glaube es hat nur indirekt was mit Interfaces zu tun. Jedenfalls probiere ich mich grad ein bisschen an
Dll-Interface-Plugins.
Wichtige Klassen etc:
Delphi-Quellcode:
_Plugin = record
hLib: THandle;
Plugin: IPlugin;
end;
_PPlugin = ^_Plugin;
//..
TPluginList = class(TList)
private
function GetItem(Index: Integer): _PPlugin;
procedure SetItem(Index: Integer; const Value: _PPlugin);
public
function Add(Item: _PPlugin): Integer;
property Items[Index: Integer]: _PPlugin read GetItem write SetItem;
end;
function TPluginList.Add(Item: _PPlugin): Integer;
begin
Result := inherited Add(Item);
end;
function TPluginList.GetItem(Index: Integer): _PPlugin;
begin
Result := _PPlugin(inherited Items[Index]);
end;
procedure TPluginList.SetItem(Index: Integer; const Value: _PPlugin);
begin
inherited Items[Index] := Value;
end;
function TForm1.LoadPlugin(DllName: PChar): _PPlugin;
var hLib: THandle;
x: TInitPlugin;
begin
hLib := LoadLibrary(DllName);
if hLib <> 0 then
begin
@x := GetProcAddress(hLib,'InitPlugin');
Result^.hLib := hLib;
Result^.Plugin := x;
end;
end;
Delphi-Quellcode:
var pTmp: _PPLugin;
begin
pTmp := LoadPlugin('Plugin.dll');
PlugInList.Add(pTmp);
//...
end;
Wenn ich mein Programm beende bekomme ich eine
AV und einen Runtime Error... Woher kommt das?
Gruß
Neutral General
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."