Crystal report顯示時會自動關閉 |
尚未結案
|
longjibo
一般會員 發表:18 回覆:18 積分:12 註冊:2002-11-08 發送簡訊給我 |
我在DLL檔中集成列印了CRYSTAL REPORT的功能,但在調用時,報表只顯示了下就自動關閉了,請問該如何解決此問題呢?
DLL語句中的FUNCTION語句如下:
調用語句為:
function RunReport(RepName:string;ParamsList,ValueList: tstringlist; Permit: string): Boolean;
type
TRunRep = function(RepName:string;ParamsList,ValueList: tstringlist; Permit: string): THandle;
var
h: THandle;
RunRep: TRunRep;
Tp: TFarProc;
x: word;
begin
Result := false;
h := LoadLibrary('RunReport.dll');
if h > 0 then
begin
try
@RunRep := GetProcAddress(h, PChar('RunAdvReport'));
if @RunRep <> nil then
begin
RunRep(RepName,ParamsList,ValueList,Permit);
result := true;
end
else
ShowMessage('RunReportº¯ÊýûÓÐÕÒµ½');
finally
FreeLibrary(h); {ÊÍ·ÅDLL}
end;
end
else
ShowMessage('RunReport.dllûÓÐÕÒµ½');
end; DLL代碼為:
unit RunCREReport; interface uses
Windows, Messages, SysUtils, Variants, Classes, Registry, Forms,
Dialogs, StdCtrls, UCrpeClasses, UCrpe32, UCrpeUtl,StrUtils; function RunAdvReport(RepName:string;ParamsList,ValueList: tstringlist; Permit: string): boolean; export;
//function GetParams(ParamsList:tstringlist):boolean;
implementation {function GetParams(ParamsList:tstringlist):boolean;
begin
end;} function RunAdvReport(RepName:string;ParamsList,ValueList: tstringlist; Permit: string): boolean;
var
Crpe1: TCrpe;
Errordate,ErrQty: boolean;
{»úÐ͵ÄÆðÖ¹±àºÅ,Éú²úÅúºÅµÄÆðÖ¹±àºÅ,ÆðÖ¹ÈÕÆÚ}
i:integer;
begin
Result := False;
Errordate:=False;
ErrQty:=False;
if RepName = '' then exit;
for i:=0 to ParamsList.Count-1 do
begin
if pos('Date',ParamsList[i])<>0 then
begin
if (ValueList[i]<>'') and (strtoint(leftstr(ValueList[i],4)) < 2000)
then
begin
Errordate := True;
break;
end
else continue;
end;
if pos('Qty',ParamsList[i])<>0 then
begin
if (ValueList[i]<>'') and (strtoint(ValueList[i])<1) then
begin
ErrQty:=True;
Break;
end
else continue;
end;
end;
if Errordate then
begin
ShowMessage('´íÎóµÄÈÕÆÚÖµ,ÇëÈ·ÈÏÊäÈëµÄÈÕÆÚÖµ²»ÄÜСÓÚ2000');
Exit;
end;
if ErrQty then
begin
ShowMessage('´íÎóµÄÊýÁ¿Öµ,ÇëÈ·ÈÏÊäÈëµÄÊýÁ¿Öµ²»ÄÜСÓÚ1');
Exit;
end;
Crpe1 := TCrpe.Create(application);
with Crpe1 do
begin
ReportName := RepName;
Connect.Clear;
showmessage(permit);
Connect.DatabaseName := 'prd';
Connect.ServerName := 'pinehj005';
Connect.UserID := 'sa';
Connect.Password := 'hjmis1234';
for i:=0 to ParamFields.Count-1 do
begin
if ParamFields.IndexOf(ParamsList[i],'')<>-1 then
ParamByName(ParamsList[i],'').CurrentValue := ValueList[i];
end;
WindowButtonBar.ExportBtn:=strtobool(copy(Permit,5,1));
WindowButtonBar.PrintBtn:=strtobool(copy(Permit,6,1));
Try
Execute;
Result:=True;
except
free;
end;
end;
// Result:=True;
end; function GetCRWPath: string;
var
s1: string;
Reg1: TRegistry;
begin
Result := '';
Reg1 := TRegistry.Create;
try
Reg1.RootKey := HKEY_LOCAL_MACHINE;
if not Reg1.OpenKey('\SOFTWARE\PMS\Reports', False) then
Exit;
s1 := Reg1.ReadString('Path');
if not IsStrEmpty(s1) then
Result := s1 '\Crw32.exe';
except
Reg1.Free;
end;
Reg1.Free;
end; end.
|
longjibo
一般會員 發表:18 回覆:18 積分:12 註冊:2002-11-08 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |