在VC 的动态库中函数的原型如下:
GetData(char * reid,char * inbuf,int inlen,char * outbuf,int * outlen);要求传过去5个参数,再把修改后的reid,outbuf,oulen 传回来,请问在Delphi里如何声明这个函数且如何调用与传递参数给这个函数.

解决方案 »

  1.   

    function GetData(reid,inhuf:pchar;inlen:integer;outbuf:pchar,outlen:pinteger);调用:
      var
        aa:array[0..7]of  byte;
        i:integer
      begin
        GetData(@aa[0],@aa[0],0,@aa[0],@i);
      end;
      

  2.   

    procedure GetData(reid:pChar;inBuf:pChar;inlen:integer;outbuf:pChar;outlen:PInteger);stdcall;external '*****.dll';
    type
      MMData=record
        code:array[0..5] of char;
        sdate:array[0..7] of char;
        edate:array[0..7] of char;
      end;procedure TForm1.Button1Click(Sender: TObject);
    var
        mData:MMData;
        out_buf:array[0..999] of char;
        reid:array[0..3] of char;
        outlen:integer;
    begin
        ZeroMemory(pChar(@mData),sizeof(mdata));
        CopyMemory(@mdata.code[0],pChar('000024'),6);
        CopyMemory(@mdata.sdate[0],pChar('20040101'),8);
        CopyMemory(@mdata.edate[0],pchar('20040110'),8);
        GetData(@reid[0],pChar(@mData),sizeof(mdata),@out_buf[0],@outlen);
    end;
      

  3.   

    char —> bytefunction GetData(reid:pbyte;inbuf:pbyte;inlen:integer;outbuf:pbyte;outlen:pinteger): longint; StdCall; external 'MYLIB.DLL';