动态库定义的地方
function Dou(i,j:integer):integer;stdcall
begin
 result:=i*j;
end;
exports
Dou;
        调用dll的地方
procedure TForm1.Button1Click(Sender: TObject);
var
h:Thandle;
begin
h:=SafeLoadLibrary('mydll.dll');
@Dou:=getprocaddress(h,'Dou'); ------出错的地方
end;到底动态调用dll应该怎么写呢?谢谢

解决方案 »

  1.   

    在impleation下加上
      TDou=Function (i,j:integer):integer;stdcall)
    var
     h:Thandle;
     f:TDou;
    begin
      h:=LoadLibrary('mydll.dll');
       if h<>0 then
       begin
         @f:=getprocaddress(h,'Dou'); 
         if @f<>nil then
         begin
          代码
         end;
    这是动态调用
      

  2.   

    你的dou要定义一下啊!
    在TYPE下面写
    Class Tdou = function ( i,j:Integer):Integer;stdcall;
    在调用的地方的VAR下面写procedure TForm1.Button1Click(Sender: TObject);
    var
    h:Thandle;
    dou:TDou;
    begin
    h:=SafeLoadLibrary('mydll.dll');
    @Dou:=getprocaddress(h,'Dou'); 
    Dou(1,2);
    end;
      

  3.   

    最好把调用的代码都TRY起来
    最后FINALLY
     FreeLibrary(LibH);