O
oicu
Unregistered / Unconfirmed
GUEST, unregistred user!
//
library MyForms;
uses
SysUtils,
Forms,
Messages,
Windows,
Classes,
UFrmBaseForm in 'UFrmBaseForm.pas' {FrmBaseForm},
UFrmSingleBase in 'UFrmSingleBase.pas' {FrmSingleBase},
UFrmDoubleBase in 'UFrmDoubleBase.pas' {FrmDoubleBase},
UPublicObject in 'UPublicObject.pas',
UDataModal in 'UDataModal.pas' {DM: TDataModule};
{$R *.res}
var
DllApp:TApplication;
{ 用于初始化:保存DLL本身的Application,然后设置DLL的Application指向Host的Application }
procedure InitDLL(App:TApplication);stdcall;
begin
DllApp:=Application;
Application:=App;
end;
{ 善后工作:恢复DLL原来的Application }
procedure FreeDLL;stdcall;
begin
Application:=DllApp;
end;
{ 这是DLL的主要功能 !!}
procedure RunDLL(DLLName, FormName: PChar;
ExeAppHandle, ExeAppIconHandle: Integer) stdcall;
var
theClass: TPersistentClass;
TheForm: TFrmBaseForm;
begin
Application.Handle := ExeAppHandle;
Application.Icon.Handle := ExeAppIconHandle;
RegisterClasses([TFrmSingleBase, TFrmDoubleBase]);
theClass := GetClass('T' + FormName);
if theClass.InheritsFrom(TForm) and (theClass <> nil) then
begin
try
TheForm := TFrmBaseForm(theClass.Create).Create(nil);
try
TheForm.ShowDLLForm;
finally
FreeAndNil(TheForm);
end;
except
raise;
end;
end;
end;
exports
InitDLL,FreeDLL,RunDLL;
begin
end.
library MyForms;
uses
SysUtils,
Forms,
Messages,
Windows,
Classes,
UFrmBaseForm in 'UFrmBaseForm.pas' {FrmBaseForm},
UFrmSingleBase in 'UFrmSingleBase.pas' {FrmSingleBase},
UFrmDoubleBase in 'UFrmDoubleBase.pas' {FrmDoubleBase},
UPublicObject in 'UPublicObject.pas',
UDataModal in 'UDataModal.pas' {DM: TDataModule};
{$R *.res}
var
DllApp:TApplication;
{ 用于初始化:保存DLL本身的Application,然后设置DLL的Application指向Host的Application }
procedure InitDLL(App:TApplication);stdcall;
begin
DllApp:=Application;
Application:=App;
end;
{ 善后工作:恢复DLL原来的Application }
procedure FreeDLL;stdcall;
begin
Application:=DllApp;
end;
{ 这是DLL的主要功能 !!}
procedure RunDLL(DLLName, FormName: PChar;
ExeAppHandle, ExeAppIconHandle: Integer) stdcall;
var
theClass: TPersistentClass;
TheForm: TFrmBaseForm;
begin
Application.Handle := ExeAppHandle;
Application.Icon.Handle := ExeAppIconHandle;
RegisterClasses([TFrmSingleBase, TFrmDoubleBase]);
theClass := GetClass('T' + FormName);
if theClass.InheritsFrom(TForm) and (theClass <> nil) then
begin
try
TheForm := TFrmBaseForm(theClass.Create).Create(nil);
try
TheForm.ShowDLLForm;
finally
FreeAndNil(TheForm);
end;
except
raise;
end;
end;
end;
exports
InitDLL,FreeDLL,RunDLL;
begin
end.