動態庫如下﹕
library jiemian;uses
SysUtils,
forms,
Classes,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
function showform:integer;stdcall;
var
form:tform1;
begin
form:=tform1.Create(application);
result:=form.ShowModal;
form.Free;
end;
exports
showform;begin
end.
form1的代码是:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Label1: TLabel;
Button1: TButton;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
close;
end;end.
library jiemian;uses
SysUtils,
forms,
Classes,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
function showform:integer;stdcall;
var
form:tform1;
begin
form:=tform1.Create(application);
result:=form.ShowModal;
form.Free;
end;
exports
showform;begin
end.
form1的代码是:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Label1: TLabel;
Button1: TButton;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
close;
end;end.
http://expert.csdn.net/Expert/topic/2383/2383337.xml?temp=7.127017E-02
将方法名和参数改一下就可以了。
請給出簡單實例嘛unit Unit1;interface
function showformx :integer;stdcall;
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
btn1: TButton; private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}{ TForm1 }function showformx;external 'project2.dll' name 'showform';end.