Main Application:
procedure TForm1.Button1Click(Sender: TObject);
var
temp:integer;
shandle:THandle;
FPointer:Pointer;
myfunc:TShowForm;
begin
shandle:= LoadLibrary('prodll');
if shandle<>0 then
try
FPointer:= GetProcAddress(shandle,'Showwindow');
if FPointer<>nil then
begin
myfunc:=TShowForm(FPointer);
myfunc;
end else showmessage('No this proc!');
finally
FreeLibrary(shandle);
end;
end;
The DLL exports:
procedure ShowWindow ; stdcall;
begin
try
application.CreateForm(TForm1,form1);
try
form1.ShowModal;
finally
form1.Free;
end;
except on E:exception do
messagedlg('Error in DllForm:'+E.message,mtError,[mbOK],0);
end;
end;
If I close the DLL's form ,the Application will close too .