在一个程序中,怎样调用一个dll文件?

解决方案 »

  1.   

    首先声明你的函数例如:
    放在
    implementation之前
      function  GetValue:Integer;Stdcall;external 'ShareDate.dll';然后就可以直接使用了
      

  2.   

    楼上说的是静态调用,也可以用动态调用的方法。用以下三个函数。
    LoadLibrary、FreeLibrary、GetProcAddress
      

  3.   

    procedure Tmain.minClick(Sender: TObject);
    //////////////////////动态加载DLL,最小化窗口
    type minwin=procedure(myform:tform);stdcall;
    var
      handle1:thandle;
      pfunc:tfarproc;
    begin
     handle1:=loadlibrary('mass.dll');
     if handle1=0 then
      begin
        showmessage('Not Found Mass.dll');
        exit;
      end;
     pfunc:=getprocaddress(handle1,'minwindow');  ///minwindow为mass.dll中的函数。
      if pfunc<>nil then
        minwin(pfunc)(self)
      else
       showmessage('Not Found Function');
       freelibrary(handle1);
      end;