FastReport 如何封装成DLL供 VB6、PB 等调用开发工具调用。
非常感谢。小弟Delphi比较弱,麻烦说详细点。拜谢!
非常感谢。小弟Delphi比较弱,麻烦说详细点。拜谢!
解决方案 »
- 如何让程序在规定的时间内执行某个按钮的功能?
- ShellExecute使用中的一个问题!
- 小问题:怎样判断一个字符是否是空格?
- 在dbgrid中怎样将指针移到满足条件的记录上去?
- 超级复杂的数据库问题
- 系统提示:[Fatal Error]Procect1.dpr(1):File Not find :'System.pas',应该怎么处理??
- (高分寻求意见!!!)想买个笔记本电脑,文字处理为主,轻薄型,价格10000元以内,请各位兄弟推荐一些好品牌和型号!
- 请问如何使用speechsdk51的内存流呀? ????????????????????
- !!!!!!请高手推测!!!!!!
- 今天真丢脸呀!在座的各位谁能一个小时内在tcontrol的基础上做出一个treeview控件来?
- 如何访问TFrame中的组件?
- 用WIN32 INTERNET API实现ftp上传文件报错
自行封装可搜索
http://www.google.com.hk/search?hl=zh-CN&q=FastReport+dll
dataList:TList;FrmName:string):Boolean;stdcall;external 'Fr_Report.dll';function GetReportList(app:TApplication;con:TADOConnection;FrmName:string;var Strs: TStringList):boolean;stdcall;external 'Fr_Report.dll';function ShowPrint(app:TApplication;adata: Pointer;conn:TADOConnection;
dataList:TList;ReportName:string;lmode:boolean):boolean;stdcall;external 'Fr_Report.dll';
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
ShareMem,
Windows,
SysUtils,
Classes,
Forms,
ADODB,
DB,
UnitFrmReport in 'UnitFrmReport.pas' {FrmReport},
WinSkinData,
UnitFrmReportEdit in 'UnitFrmReportEdit.pas' {FrmReportEdit},
UnitPrintFrm in 'UnitPrintFrm.pas' {PrintFrm};{$R *.res}
var
DllApplication: TApplication;
//根据窗口名称/报表编号打印/预览报表;
//参数列表
//App:当前工程;
//adata 皮肤窗口需要传得参数;
//con:数据库格式文件存储的数据库联接;
//datalist:打印的数据集列表;
//Frmname:窗口名称;
function ShowReportFrm(app:TApplication;adata: Pointer;con:TADOConnection;
dataList:TList;FrmName:string):Boolean;stdcall;
begin
Result:=False;
application:=app;
Winskindata.SkinDll(adata);
FrmReport:=TFrmReport.Create(app);
if Assigned(dataList) then
FrmReport.DataList:=dataList;
FrmReport.frmname:=frmname;
frmReport.adoSetMain.Connection:=con;
FrmReport.adoSetMain.CommandText:='select * from ReportFileRec where FrmName='+#39+FrmName+#39;
FrmReport.adoSetMain.Open;
FrmReport.ShowModal;
FrmReport.Free;
Result:=True;
end;function GetReportList(app:TApplication;con:TADOConnection;FrmName:string;var Strs: TStrings):boolean;stdcall;
var
adoset:TADODataSet;
i:integer;
begin
application:=app;
adoset:=TADODataSet.Create(nil);
adoset.Connection:=con;
adoset.CommandText:='select * from ReportFileRec where FrmName='+#39+FrmName+#39;
adoset.Open;
if not adoset.IsEmpty then
begin
adoset.First;
for i:=0 to adoset.RecordCount-1 do
begin
Strs.Add(adoset.fieldbyname('ReportName').Value);
adoset.Next;
end;
end;
adoset.Free;
end;function ShowPrint(app:TApplication;adata: Pointer;conn:TADOConnection;
dataList:TList;ReportName:string;lmode:boolean):boolean;stdcall;
var
Dataset:TADODataSet;
i:integer;
begin
Result:=false;
application:=app;
Winskindata.SkinDll(adata);
Dataset:=TADODataSet.Create(nil);
Dataset.CommandText:='Select * from ReportFileRec where ReportName='+#39+ReportName+#39;
Dataset.Connection:=conn;
Dataset.Open;
if Dataset.IsEmpty then Exit;
ShowReport(dataList,TBlobField(dataset.FieldByName('ReportFile2')),lmode,Reportname);
dataset.Free;
end;procedure DLLUnloadProc(Reason: Integer); register;
begin
if Reason = DLL_PROCESS_DETACH then
begin
Application:=DllApplication;
end;
end;exports
ShowReportFrm,
ShowPrint,
GetReportList;
begin
DllApplication:=Application;
DLLProc := @DLLUnloadProc;
end.
1.调用时变量出错,最普通的一个变量注入也是一样
2.出现Cannot assign a TFieldList to a TStringList的错误
3.Invalid pointer operation的错误,在函数中返回WideString引起的以下是解决办法:1.不要在DLL中直接引用FastReport的单元文件,最好用一个接口类来实现 ,做法如下:
a.定义公共类接口
b.在主程序中实现该接口类
c.把接口类的实例指针传给DLL
d.在dll中调用公共类的方法,以实现注入变量与数据集的功能
2.修改frxDBSet.pas中的procedure TfrxDBDataset.GetFieldList(List: TStrings);
var
i: Integer;
begin
List.Clear;
if FieldAliases.Count = 0 then
begin
try
if FDS <> nil then
for i := 0 to FDS.FieldCount - 1 do //<--新加的
List.Add(FDS.Fields[i].FullName); //<--新加的
//FDS.GetFieldNames(List); //<--旧的函数
except
end;
end
else
begin
for i := 0 to FieldAliases.Count - 1 do
if Pos('-', FieldAliases.Names[i]) <> 1 then
List.Add(FieldAliases.Values[FieldAliases.Names[i]]);
end;
end;3.非常重要的一点,要在主程序和DLL中都引用ShareMem单元文件,否则在获取数据集显示的字符串时将出现错误!跟踪一下就知道了...