procedure TForm1.Button1Click(Sender: TObject);{工程文件}
var
   f_max: function (X, Y:Integer):Integer; stdcall;
begin
   dllinstance:=loadlibrary('dll.dll');
   f_max := getprocaddress(dllinstance,'Max');
   edit1.text:=inttostr(f_max(2, 5));
   freelibrary(dllinstance);
end;

解决方案 »

  1.   

    好像不对,我编译通不过。
    var
      f_max: function (X, Y:Integer):Integer; stdcall;
    这句有错。
      

  2.   

    Nicrosoft兄:
       var
      pfunc: function (X, Y:Integer):Integer; stdcall;
      pfunc:tfarproc;
     这两句有什么区别或者说应怎么理解?
      

  3.   

    你可以在type中定义:type
       pFuncType = function (X, Y:Integer):Integer; stdcall;然后
    var pfunc: pFuncType; 也可以TFarProc也是一个函数指针罢了
      

  4.   

    调用不用那么复杂吧?
    这样行不行?
    function max(x,y:integer):integer;external 'dll.dll' index 1; 
      

  5.   

    你这是静态调用,如果dll文件不存在,你的exe就无法运行了。