以上代码在D7上测试有点问题:
===============
下面的测试OK的
[Delphi] 纯文本查看 复制代码 Delphi7中编译成功的:
=====================这是带界面的DLL部分(Project1.dpr)
library Project1;
uses
SysUtils,
Classes,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
function ShowDllForm:TForm1;stdcall;
begin
Result := TForm1.Create(nil);
Result.Show;
end;
{$R *.res}
exports
ShowDllForm;
begin
end.
==============上面是调用DLL的主界面部分:====================
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function ShowDllForm:TForm1;external 'Project1.dll'
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowDllForm;
end;
end.
|