蓝
蓝叶菱
Unregistered / Unconfirmed
GUEST, unregistred user!
最近看李维的老帖子,关于动态包的使用问题...
不知道为什么我的函数没有取到这个类...
procedure TFrmMain.LoadMyPackage;
begin
try
FModule:=LoadPackage('dclDM.bpl');
LoadDataModule;
except
on E:Exception do begin
ShowMessage('出错了!错误号码:'+E.Message);
Abort;
end;
end;
end;
procedure TFrmMain.FormActivate(Sender: TObject);
begin
LoadMyPackage;
end;
procedure TFrmMain.LoadDataModule;
var
iCount:integer;
begin
DataModuleClass:=GetClass('TDM');
if DataModuleClass<>nil then //存在该类开始创建TDATAMOUDLE,为什么取到的类是空的?这里居然跳过...
begin
admGlobal:=TDataModule(TComponentClass(DataModuleClass).Create(Application));
for iCount:=0 to admGlobal.ComponentCount-1 do begin
if UpperCase(admGlobal.Components[iCount].ClassName)='TAdoQuery' then begin
aQuery:=TADOQuery(admGlobal.Components[iCount]);
ds.DataSet:=aQuery;
aQuery.Connection.Open;
ds.DataSet.Open;
break;
end;
end;//for
end;
end;
代码地址:
http://www.xazjj.gov.cn/westsky2/packdemo.rar
不知道为什么我的函数没有取到这个类...
procedure TFrmMain.LoadMyPackage;
begin
try
FModule:=LoadPackage('dclDM.bpl');
LoadDataModule;
except
on E:Exception do begin
ShowMessage('出错了!错误号码:'+E.Message);
Abort;
end;
end;
end;
procedure TFrmMain.FormActivate(Sender: TObject);
begin
LoadMyPackage;
end;
procedure TFrmMain.LoadDataModule;
var
iCount:integer;
begin
DataModuleClass:=GetClass('TDM');
if DataModuleClass<>nil then //存在该类开始创建TDATAMOUDLE,为什么取到的类是空的?这里居然跳过...
begin
admGlobal:=TDataModule(TComponentClass(DataModuleClass).Create(Application));
for iCount:=0 to admGlobal.ComponentCount-1 do begin
if UpperCase(admGlobal.Components[iCount].ClassName)='TAdoQuery' then begin
aQuery:=TADOQuery(admGlobal.Components[iCount]);
ds.DataSet:=aQuery;
aQuery.Connection.Open;
ds.DataSet.Open;
break;
end;
end;//for
end;
end;
代码地址:
http://www.xazjj.gov.cn/westsky2/packdemo.rar