![]() |
TList und Interfaces Problem
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:
Wenn ich mein Programm beende bekomme ich eine AV und einen Runtime Error... Woher kommt das?
var pTmp: _PPLugin;
begin pTmp := LoadPlugin('Plugin.dll'); PlugInList.Add(pTmp); //... end; Gruß Neutral General |
Re: TList und Interfaces Problem
Hallo Michael,
du forderst in der Methode TForm1.LoadPlugin keinen Speicher für das Funktionsergebnis an. Gruß Hawkeye |
Re: TList und Interfaces Problem
Ja das kann schon sein.. Nur wie mach ich das ? :|
|
Re: TList und Interfaces Problem
Delphi-Quellcode:
wäre die einfachste Lösung.
New (Result);
Gruß Hawkeye |
Re: TList und Interfaces Problem
Ok danke es klappt jetzt :)
Gruß Neutral General |
Alle Zeitangaben in WEZ +1. Es ist jetzt 08:03 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-2025 by Thomas Breitkreuz