简单问题求解!!
xzhr 2001-08-01 10:08:37 小弟制作一窗体程序,将WinPro.dpr文件修改如下:
library WinPro;
uses
WinDll in 'WinDll.pas' {Form1};
exports ShowPassWindow;
{$R *.RES}
begin
end.
而WinDll.pas文件如下:
unit WinDll;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
procedure ShowPassWindow(AHandle:THandle;ACaption:string);stdcall;
implementation
procedure ShowPassWindow(AHandle:THandle;ACaption:string);
var
DLLForm:TForm1;
begin
Application.Handle:=AHandle;
DLLForm.Create(Application);
DLLForm.Caption:=ACaption;
try
DLLForm.ShowModal;
finally
DLLForm.Free;
end;
end;
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
Close;
end;
end.
经保存得到WinPro.dll文件,退出,在一新程序中作如下处理:
声明:
procedure ShowPassWindow(AHandle:THandle;ACaption:string);stdcall;external 'winpro.dll';
在Button1的单击处理函数中代码如下
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowPassWindow(Application.Handle,'ok');
end;
运行程序:单击button1,出错