如果你将你想将Form以ActiveX组件的形式存入DLL则应如下方式写DLL:
library DICDLL;
uses
SysUtils,
Classes,
Forms,
ActiveX,
EncodeFrm in 'EncodeFrm.pas' {FrmEncode},//这是本人的秘密Form,不能给你的
frmDecode in 'frmDecode.pas' {FormDecode};//这也是本人的秘密Form,不能给你的
{$R *.RES}
procedure OpenEncodeForm;
begin
try
FrmEncode:=TFrmEncode.Create(nil);
FrmEncode.ShowModal;
finally
FrmEncode.Free;
end;
end;
procedure OpenDecodeForm;
begin
try
FormDecode:=TFormDecode.Create(nil);
FormDecode.ShowModal;
finally
FormDecode.Free;
end;
end;
exports
OpenEncodeForm,
OpenDecodeForm;
begin
CoInitialize(nil);
end.
调用单元如下:
unit DLLDICFrmUnt;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure OpenEncodeForm
external 'DICDLL.DLL'
procedure OpenDecodeForm
external 'DICDLL.DLL'
procedure TForm1.Button1Click(Sender: TObject);
begin
OpenEncodeForm;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
OpenDecodeForm
end;
end.