![]() |
PlugIn DLL laden
Hi,
ich möchte ein Plugin system schreiben dabei lade ich mit folgenden code die plug in dll:
Delphi-Quellcode:
Eine dll kann man mit dem Code auch laden aber bei der 2 DLL kommt eine AV. Woran liegt das ?
type
TProcInitPlg = procedure (ixi :IIxion; hlib: integer); procedure TIxionPlugInSystem.LoadPlugIn(FFilename: string); var aProc: TProcInitPlg; hDLL: HWND; fProc: TFarProc; inter: IIxion; // interface begin hDll := LoadLibrary(PChar(FFilename)); if hDLL <> 0 then begin fProc := GetProcAddress(hDLL,'init'); if fProc <> nil then begin @aProc := fProc; end else Exit; inter:=Self; aProc(inter, hDll); AddHLib(hDLL); end; end; procedure TIxionPlugInSystem.AddHLib(h: integer); begin setlength(List, length(List)+1); // List ist array of integer List[length(List)-1]:= h; end; mfg, Björn |
Re: PlugIn DLL laden
hast du schon mal debuggt?
bei welcher Codezeile trit der fehler auf? was ist die Variable List genau? Array? was ist der typ TFarProc? Warum so?
Delphi-Quellcode:
und nicht so?
fProc := GetProcAddress(hDLL,'init');
if fProc <> nil then begin @aProc := fProc;
Delphi-Quellcode:
aProc := GetProcAddress(hDLL,'init');
if aProc = nil then exit; |
Re: PlugIn DLL laden
Zitat:
Zitat:
Zitat:
ok hab denn code geändert aber da tut sich nichts |
Re: PlugIn DLL laden
Zitat:
Gruesse, Lizzy |
Re: PlugIn DLL laden
Hallo,
hier mal meine Vermutung: Du übergibst Dein Plugin-Syste als Interface an die DLL. Du hast aber sonst keinerlei Referenzen auf dieses Interface. Jetzt passiert Folgendes:
Gruß xaromz |
Re: PlugIn DLL laden
ok hab den code etwas geändert und alles als const übergeben:
Delphi-Quellcode:
Jetzt klappt es :)Jedoch habe ich keine ahnung was ein Referenzzähler ist oder wie man im Debugger zeilenweise vorrückt :roll:
procedure TIxionPlugInSystem.LoadPlugIn(FFilename: string);
var aProc: TProcInitPlg; hDLL: HWND; fProc: TFarProc; inter: IIxion; begin hDll := LoadLibrary(PChar(FFilename)); if hDLL <> 0 then begin fProc := GetProcAddress(hDLL,'init'); if fProc = nil then exit; @aProc := fProc; aProc(Self, hDll); AddHLib(hDLL); end; end; |
Re: PlugIn DLL laden
Hallo,
Zitat:
Zitat:
Referenzzähler: Da hab' ich mal ein ![]() Gruß xaromz |
Re: PlugIn DLL laden
danke für das tutorial, wie gesagt ich hab alles auch die widestrings als const übergeben... by the way widestrings sind wirkliche eine gute alternative strings bei dlls :)
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 01: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-2025 by Thomas Breitkreuz