DLL mit VCL
-
Hallo.
Unter Suchen fand ich viel, aber nix half mir.

Ich habe eine DLL erstellt wo eine TForm mit einem Edit und 2 Buttons.
Wenn ich diese statisch in meine EXE einbinde (mittels .lib) geht es, aber ich möchte es ja dynamisch haben, um die DLLs austauschen zu können.DLL Formular Code
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Unit2.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TDLLForm *DLLForm; //extern AnsiString stext; __declspec(dllexport) void FormShow(TComponent* Owner) { TDLLForm* DLLForm = new TDLLForm(Owner); DLLForm->ShowModal(); } //--------------------------------------------------------------------------- __fastcall TDLLForm::TDLLForm(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TDLLForm::Button1Click(TObject *Sender) { Edit1->Text="huhu"; } //--------------------------------------------------------------------------- void __fastcall TDLLForm::Button2Click(TObject *Sender) { // Edit1->Text=stext; } //---------------------------------------------------------------------------In EXE Formular
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; AnsiString stext; __declspec(dllimport) void FormShow(TComponent* Owner); //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { stext = "Dieser Text soll im TEdit der DLL zu sehen sein"; } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { if (!DllInstance) DllInstance = LoadLibrary("Project1.dll"); // DLL laden if (DllInstance) Form1->Caption = "DLL wurde geladen."; FormShow(Application); } //--------------------------------------------------------------------------- void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action) { if (DllInstance) { if (FreeLibrary(DllInstance)) DllInstance = NULL; // DLL entladen } if (!DllInstance) { ShowMessage("DLL nicht entladen"); } } //---------------------------------------------------------------------------Er meldet mir : [Linker Fehler] Unresolved external 'FormShow(Classes::TComponent *)' referenced from \UNIT1.OBJ
Wie bekomme ich nun die DLLForm "richtig" dynamisch geladen. Den momentan mach ichs wohl total falsch
Zusätzlich:
Die Variable "AnsiString stext" (momentan auskommentiert weil ich nicht weiss wie) möchte ich in der DLLForm nutzen.
Per druck auf DLLForm->Button2 soll im DLLForm->Edit1 der Text erscheinen den ich zuvor in meiner EXE Anwendung definiert habe.Wie exportiere/importiere ich Variablen zwischen der DLLForm und meiner EXE Form?
Als wäre für jede nützliche Hilfe mehr als Dankbar, da ich jetzt schon paar stunden an dem Problem hänge .
-
Mach mal nen Prototyp von
__declspec(dllexport) void FormShow(TComponent* Owner)
PS: am besten in einer .h Datei