var  LibHandle   : THandle;try
  LibHandle := LoadLibrary('RegDll.dll');
  if LibHandle <> 0 then
  QryClient.FieldByName('sCode').AsString := SwichPY(edtName.Text)
finally
  FreeLibrary(LibHandle);
end;// 注:第一次调用正常,以后报错,错误提示如下
---------------------------
Debugger Exception Notification
---------------------------
Project Book.exe raised exception class EAccessViolation with message 'Access violation at address 002B1DC4 in module 'RegDLL.dll'. Write of address 00000026'. Process stopped. Use Step or Run to continue.
---------------------------
OK   Help   
---------------------------

解决方案 »

  1.   

    动态DLL需要GetProcAddress的,你的怎么没的?静态连接DLL一样基本没影响动态的好处是灵活而已http://lysoft.7u7.net
      

  2.   

    procedure calldllproc(s_dll,s_dllproc: string);
    var
      MyFunc: Procedure(AHandle: THandle);stdcall;
      libh:THandle;
    begin
      libh:=loadlibrary(pchar(s_dll));
      if libh>0 then
      begin
        try
          @MyFunc:=getprocaddress(libh,pchar(s_dllproc));
          If @MyFunc <> nil then
            MyFunc(Application.Handle)
          else
            showmessage('CallDllFailed:调用失败.找不到'+s_dllproc+'接口函数.');
        finally
          freelibrary(libh);
        end;
      end
      else
        showmessage('CallDllFailed:调用失败.找不到'+s_dllproc+'接口函数.');
    end;如何调用这个过程应该不用说了吧