dll和应用程序中都有一个DataModule,里面有ADOConnection。应用程序中的ADOConnection已配置并连接上数据库,dll中的ADOConnection未配置,由应用程序将其中的ADOConnection传给dll中的ADOConnection,总是出现“无效的授权说明”,但是将dll中ADOConnection配置好,就没有问题了是什么原因?本人刚开始使用Delphi,望高手指点,谢谢!
主要的程序代码如下:
Dll中的exports函数有:
//GetForm用来查找dll中的窗体
function GetForm(ClassName :PChar):TFormClass;stdCall;
begin
    Result := TFormClass(FindClass(ClassName));
end;//InitDll函数用来初始化dll
procedure InitDll(H:THandle;cnn:TADOConnection);stdCall;
begin
  Application.Handle:=H;
  DataModule1 :=TDataModule1.Create(Application);
  DataModule1.ADOConnection1 := cnn;
end;应用程序中主要调用代码如下:
  //初始化dll,将应用程序中的Application和ADOConnection1传递给Dll
  DllHandle := LoadLibrary('dll\CustManager.dll');
  if DllHandle<>0 then
  begin
    FarProc := GetProcAddress(DllHandle,'InitDll');
    if Assigned(FarProc) then
    begin
      InitDll := TInitDll(FarProc);
      InitDll(Application.Handle,DataModule1.ADOConnection1);
    end;
  end;  //查找Dll中的窗体,找到创建窗体并显示,
  //该窗体中的ADOQuery1用到ADOConnection1,
  //一旦调用ADOQuery1.Open就出现上面说的错误
  if DllHandle<>0 then
  begin
    FarProc := GetProcAddress(DllHandle,'GetForm');
    if Assigned(FarProc) then
    begin
      GetForm := TGetForm(FarProc);
      Form := GetForm('TCustSeekForm').Create(Application);
      Form.Show;
    end;
  end;各位高手看看什么问题,请给予指点,在此深表感谢!

解决方案 »

  1.   

    本人刚开始学习使用Delphi,望各位多多指点,谢谢!
      

  2.   

    不能直接向DLL中的procedure传递delphi的对象引用。把DLL项目修改成BPL项目就OK了。
      

  3.   

    你只能使用ADO的原生对象来解决问题,如_Connection、_Recordset、_Command等.
      

  4.   

    to ZSR
    你只能使用ADO的原生对象来解决问题,如_Connection、_Recordset、_Command等.能不能说的具体点,谢谢!
      

  5.   

     TO 楼主:   我也碰到这样的问题,请把解决方法发给我好吗,[email protected]
      

  6.   

    TO 楼主:  我也碰到这样的问题,请把解决方法发给我好吗,[email protected]
      

  7.   

    TO 楼主:  我也碰到这样的问题,请把解决方法发给我好吗,[email protected]
      

  8.   

    TO 楼主:  我也碰到这样的问题,请把解决方法发给我好吗,[email protected]