S
shhw
Unregistered / Unconfirmed
GUEST, unregistred user!
我有一个包含了很多函数和过程的Global单元。现在我想把这个单元添加到一个Dll里面封装起来,为什么在调用时老是错误呢?
调用代码为:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB, Grids, DBGridEh;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
DBGridEh1: TDBGridEh;
DataSource1: TDataSource;
ADOQuery1: TADOQuery;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
function DbGridEHOutTO_Excel(Ahand:THandle;DbGridEH:TDbGridEH;AtitleName,
ACreateDate,ACreator:string):Boolean; external 'ControlObject.dll';
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
DbGridEHOutTO_Excel(Self.Handle, DBGridEh1,'shuju','2005','shw');
end;
dll 的代码为:
library ControlObject;
uses
SysUtils,ComCtrls,dbgridEH,
Dialogs,
Forms,
Classes,
Uglobal in 'Uglobal.pas';
{$R *.res}
function DbGridEHOutTO_Excel(Ahand:THandle;DbGridEH:TDbGridEH;AtitleName,
ACreateDate,ACreator:string):Boolean;stdcall;
begin
Result := False;
try
Application.Handle := Ahand ;
DbGridEHTO_Excel(DbGridEH,AtitleName,ACreateDate,ACreator);
except
exit;
end;
Result := True;
end; exports DbGridEHOutTO_Excel;
begin
end.
说明:DbGridEHTO_Excel(DbGridEH,AtitleName,ACreateDate,ACreator);
是在单元'Uglobal.pas'的一个过程
在调用dll时总是不能通过请高手指点一二。
调用代码为:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB, Grids, DBGridEh;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
DBGridEh1: TDBGridEh;
DataSource1: TDataSource;
ADOQuery1: TADOQuery;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
function DbGridEHOutTO_Excel(Ahand:THandle;DbGridEH:TDbGridEH;AtitleName,
ACreateDate,ACreator:string):Boolean; external 'ControlObject.dll';
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
DbGridEHOutTO_Excel(Self.Handle, DBGridEh1,'shuju','2005','shw');
end;
dll 的代码为:
library ControlObject;
uses
SysUtils,ComCtrls,dbgridEH,
Dialogs,
Forms,
Classes,
Uglobal in 'Uglobal.pas';
{$R *.res}
function DbGridEHOutTO_Excel(Ahand:THandle;DbGridEH:TDbGridEH;AtitleName,
ACreateDate,ACreator:string):Boolean;stdcall;
begin
Result := False;
try
Application.Handle := Ahand ;
DbGridEHTO_Excel(DbGridEH,AtitleName,ACreateDate,ACreator);
except
exit;
end;
Result := True;
end; exports DbGridEHOutTO_Excel;
begin
end.
说明:DbGridEHTO_Excel(DbGridEH,AtitleName,ACreateDate,ACreator);
是在单元'Uglobal.pas'的一个过程
在调用dll时总是不能通过请高手指点一二。