//xcqcheck.pas dll库的实现部分
unit xcqcheck;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Mask;type
Txcqform = class(TForm)
xcqedit: TMaskEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
XcqForm: TXcqForm;
Check: Boolean;//验证输入密码的正确性
function CheckPassword: Boolean;export;implementation{$R *.DFM}procedure Txcqform.Button1Click(Sender: TObject);
begin
if XcqEdit.Text = 'xcq' then begin
Check := True;
showmessage('password confirmed');
end;
Close;
end;function CheckPassword;export;
begin
Check := False;
XcqForm := TXcqForm.Create(Application);
XcqForm.ShowModal;//显示密码输入框;
Result := Check;//返回给调用本dll的应用程序判断
XcqForm.Free;//释放本dll文件所占资源
end;end.//CheckPasswordForm.dpr,dll文件
library CheckPasswordForm;{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. } uses
XcqCheck in 'XcqCheck.pas' {XcqForm}; exports
CheckPassword name 'CheckPassword';//dll入口 begin
end.
unit Unit1;//unit1.pas,调用例子interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation
function CheckPassword: Boolean; external 'CheckPasswordForm.dll' name 'CheckPassword';
{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
begin
if CheckPassword then
begin
showmessage('sdfdsf');
end;
end;end.
unit xcqcheck;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Mask;type
Txcqform = class(TForm)
xcqedit: TMaskEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
XcqForm: TXcqForm;
Check: Boolean;//验证输入密码的正确性
function CheckPassword: Boolean;export;implementation{$R *.DFM}procedure Txcqform.Button1Click(Sender: TObject);
begin
if XcqEdit.Text = 'xcq' then begin
Check := True;
showmessage('password confirmed');
end;
Close;
end;function CheckPassword;export;
begin
Check := False;
XcqForm := TXcqForm.Create(Application);
XcqForm.ShowModal;//显示密码输入框;
Result := Check;//返回给调用本dll的应用程序判断
XcqForm.Free;//释放本dll文件所占资源
end;end.//CheckPasswordForm.dpr,dll文件
library CheckPasswordForm;{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. } uses
XcqCheck in 'XcqCheck.pas' {XcqForm}; exports
CheckPassword name 'CheckPassword';//dll入口 begin
end.
unit Unit1;//unit1.pas,调用例子interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation
function CheckPassword: Boolean; external 'CheckPasswordForm.dll' name 'CheckPassword';
{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
begin
if CheckPassword then
begin
showmessage('sdfdsf');
end;
end;end.
其实我只想写一个对文件操纵的函数到DLL,不带窗口的,怎么做啊?
还有编译出的DLL为什么不能增加版权信息???
library Project2;{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }uses
SysUtils,
Classes;{$R *.RES}function pingfang(x:integer):integer;
begin
result:=x*x;
end;
exports pingfang name 'pingfang';
end.
//调用
var
Form1: TForm1;implementation{$R *.DFM}
function pingfang(x:integer):integer;external 'project2.dll';procedure TForm1.FormCreate(Sender: TObject);
begin
showmessage(inttostr(pingfang(50)));
end;end.
project-->options-->version info -> 钩选 include version information in project,然后就随你填了