先看看这一段代码:
procedure THR_mainform.modclick(sender:Tobject); //模块事件加载过程
var
labname: string;
iCounter:Integer;
Oxmarq:ToxMarquee;
SQLString:String; //QUERYPRO参数值
Tagkey:string;
begin
if sender is ToxGraphicButton then
begin
labname:=(sender as ToxGraphicButton).Name ;
Querypro.Connection :=form_login.ado;
Querypro.Parameters.ParamValues['labelname']:=labname;
querypro.Active :=true;
with querypro do
begin
if fieldbyname('程序类型').AsString ='.exe' then //==============如果调用的是.exe时
begin
if ShellExecute(handle,'open',pchar(fieldbyname('程序名称').AsString+'.exe'),pchar(fieldbyname('Parameter').AsString),nil,SW_SHOWMAXIMIZED)<32 then
begin
ShowMessage(SysErrorMessage(GetLastError));
labname:='';
querypro.Active :=false;
end;
end
else// =================================================如果调用的是bpl时
if fieldbyname('程序类型').AsString ='.bpl' then
begin
AQ_selectsql.Connection :=form_login.ado ;
showmessage(fieldbyname('tag').AsString) ;
tagkey:= trim(fieldbyname('tag').AsString);
AQ_selectsql.Parameters.ParamValues['tagkey']:=tagkey ;
AQ_selectsql.Active :=true;
with AQ_selectsql do
begin
SQLString:='select * from' +' '+fieldbyname('v_table').AsString+' '+'where'+' '+fieldbyname('wherekey').AsString +' '+'order by'+' '+fieldbyname('orderby').AsString ;
Showmessage(SQLString) ;
end;
AQ_selectsql.Close ;
try
Loadbpl := LoadPackage(fieldbyname('程序名称').AsString+'.bpl');
Formbpl := TCustomForm(TComponentClass(FindClass(fieldbyname('包类').AsString)).Create(Application));
for iCounter := 0 to Formbpl.ComponentCount - 1 do
begin
if UpperCase(Formbpl.Components[iCounter].ClassName) ='TADOQUERY' then
begin
AQ_CONN:=TADOQUERY(Formbpl.Components[iCounter]);
AQ_CONN.Connection :=Form_login.ado;
AQ_CONN.SQL.Add(sqlString);
break;
end;
end;
for iCounter := 0 to Formbpl.ComponentCount - 1 do
begin
if UpperCase(Formbpl.Components[iCounter].ClassName) ='TOXMARQUEE' then
begin
Oxmarq:=TOXMARQUEE(Formbpl.Components[iCounter]);
Oxmarq.Caption:=tagkey;
break;
end;
end;
//Formbpl.show;
Formbpl.showmodal;
mustfreebpl:=true;
finally
labname:=''; //清除变量
querypro.Active :=false; //断开链接
end;
end
else//=====================================================如果调用的是dll时
if fieldbyname('程序类型').Asstring ='.dll' then
begin
showmessage('不能打开这种类型的程序') ; //需修改
labname:='';
querypro.Active :=false;
end
else
showmessage('没有这种454类型的程序');
labname:='';
querypro.Active :=false;
end;
end;
end;