Delphi7 调用 C 的DLL的问题,急!
DLL的接口函数是这样定义的int ykt_readopencardinfo_local (char *pRegion, char *pDeptid,char *pDeptKey, char *pIssuedeptid,char *pIssuedate, char *pCardtype,char *pCardno,char *pIdtype,char *pId,char *pName, char *pSex,char *pBirthDate,char *pCompany,char *pAddress,char *pTelephone, char *pWarnmsg,char *pErrmsg)。
Delphi程序:
声明:
function ykt_readopencardinfo_local(pRegion: string; pDeptid: string; pDeptKey: string; var pIssuedeptid: PChar; var pIssuedate: PChar; var pCardtype: PChar; var pCardno: PChar;
var pIdtype: PChar; var pId: PChar; var pName: PChar; var pSex: PChar; var pBirthDate: PChar; var pCompany: PChar; var pAddress: PChar; var pTelephone: PChar; var pWarnmsg: PChar; var pErrmsg: PChar): Integer; stdcall; external 'fzyktclient.dll';
调用:
pstr8:=StrAlloc(49);
pstr9:=StrAlloc(17);
pstr10:=StrAlloc(11);
pstr11:=StrAlloc(41);
pstr12:=StrAlloc(11);
pstr13:=StrAlloc(49);
pstr14:=StrAlloc(25);
pstr15:=StrAlloc(11);
pstr16:=StrAlloc(17);
pstr17:=StrAlloc(121);
pstr18:=StrAlloc(49);
pstr19:=StrAlloc(49);
pstr20:=StrAlloc(1051);
pstr21:=StrAlloc(1051);
retCode:=ykt_readopencardinfo_local(ls_Region, ls_DeptID, ls_DeptKey,
pstr8, pstr9, pstr10, pstr11, pstr12, pstr13, pstr14, pstr15, pstr16, pstr17,
pstr18, pstr19,pstr20, pstr21);
Showmessage(strpas(pstr13)); //出错
strCopy(@buf_pId, @pstr13); //其中 var buf_pId: array[0..48] of Char;
Edit4.Text := buf_pId; //字符错位,比如返回结果应该是 pstr8='12345' pstr9='abcde',但返回的结果是 pstr9='12345 abcde' pstr8='5 abcde'比pstr9少前面四个字符。
StrDispose(pstr21); //出错 报地址错误。
另外:还有用动态调用静态调用都不行,stdcall改成dcall也不行,声明中PChar改成PLStr也不行。
已经山穷水尽了,请好心人帮帮忙!