Thema: Delphi Mainform aus DLL laden?

Einzelnen Beitrag anzeigen

Benutzerbild von Sunlight7
Sunlight7

Registriert seit: 17. Sep 2006
Ort: Sonnensystem, Zentral
1.522 Beiträge
 
Delphi 5 Standard
 
#13

Re: Mainform aus DLL laden?

  Alt 13. Jan 2009, 15:34
Also an dem DLL Code liegts wohl nicht, habe folgendes getestet, funkt wunderbar, bis auf das, das die Form kein Icon hat.
Nur würde ich den Export vllt nicht gerade MainForm nennen, vllt beisst sich der Name mit etwas

Delphi-Quellcode:
library Project1;

uses
  Forms,
  Windows,
  SysUtils,
  Classes,
  Unit1 in 'Unit1.pas{Form1};

procedure Test(AppHandle:THandle); stdcall;
begin
   Application.Handle:=appHandle;

   try
     with TForm1.Create(Application) do begin
        ShowModal;
        Free;
     end;
   except
     On E : exception Do Application.HandleException(E);
   end;
  Application.Handle := 0;
end;

exports Test;

begin
end.
Delphi-Quellcode:
program Project1;

uses
  Windows,
  Forms;

{$R *.RES}

   var Lib:Cardinal;
       Test:procedure(AppHandle:THandle); stdcall;
begin
  Application.Initialize;


   Lib:=LoadLibrary('Project1.dll');
   Test:=GetProcAddress(Lib, 'Test');
   If Assigned(Test) then Test(Application.Handle);

   // Grad zu faul um Ress frei zu gegeben

  Application.Run;
end.
Windows: Ja - Microsoft: Nein -> www.ReactOS.org
  Mit Zitat antworten Zitat