请教大虾:
我将Dll文件放在程序所在目录的一个子目录下,而不在系统目录或程序所在主目录下,用delphi如何调用这些Dll文件的函数?同时这些Dll文件也需要互相调用对方的函数。

解决方案 »

  1.   

    type TMatchSearcher= function (wanting,founding:PChar):boolean; stdcall;
    var
     s1,s2,dllpath:string;
     i:Longint;
     hInstDLL:THandle;
     pms1:TMatchSearcher ;
    begin
    s1:=trim(edit2.Text );
    listbox2.Items.Clear ;
    hasfenxip:=false;dllpath:=ExtractFilePath(Application.ExeName )+'\新建文件夹\tongpeidll.dll';
    hInstDLL := LoadLibrary(PChar(dllpath) );
    if(hInstDLL =0) then exit;
    @pms1 :=GetProcAddress(hInstDLL ,'MatchSearcher');
    if (@pms1=nil) then exit;for i:=0 to Memo1.Lines.Count -1 do
      begin
        s2:=Memo1.Lines.Strings[i];
        if pms1(PChar(s1),PChar(s2)) then
       // if MatchSearcher(PChar(s1),PChar(s2)) then
          begin
            listbox2.Items.Add(s2);
          end;
      end;
      if (hInstDLL<>0) then  FreeLibrary(hInstDLL);
    end;