F
fwd
Unregistered / Unconfirmed
GUEST, unregistred user!
用接口封装类.以下静态调用没有问题. function CreateDBTreeForm(DataSet:TDataSet; FieldCode,FieldName, LevelStru,TreeMean:string):IDBTree; stdcall; external 'DBTree.DLL';可用动态调用出现 EAccessViolation错误,存储地址违例. 不知为什么? 请大伙帮忙.以下是动态装载DLL代码:type TCreateDBTreeForm=function(DataSet:TDataSet; FieldCode,FieldName,LevelStru,TreeMeanChar):IDBTree; stdcall; {返回管理树形TreeForm信息的接口} function CreateDBTreeForm(DataSet:TDataSet; FieldCode,FieldName,LevelStru,TreeMeanChar):IDBTree; ...implementationfunction CreateDBTreeForm(DataSet:TDataSet; FieldCode,FieldName,LevelStru,TreeMeanChar):IDBTree;var Handle: THandle; Link: TCreateDBTreeForm;begin Handle := LoadLibrary('DBTree.DLL'); Try if Handle <> 0 then begin @Link:=GetProcAddress(Handle, PChar('CreateDBTreeForm')); if Assigned(@Link) then result:=Link(DataSet,PChar(FieldCode),PChar(FieldName), PChar(LevelStru),PChar(TreeMean)); end else BoxError('找不到文件 DBTree.DLL!'); finally FreeLibrary(Handle); end;end;调用代码: ITree:=CreateDBTreeForm(ADOQuery1, PChar('Office'),PChar('Name'),PChar('122'),PChar('部门')); ITree.ShowWithModal(False);