6.11. 得到部门信息列表
long CapGetDepList(DOWNDEPINFO *pINFO)
6.11.1. 功能描述
得到所有的部门信息
6.11.2. 参数说明
入口参数
DOWNDEPINFO *pINFO 指向部门信息结构数组的指针,参见结构详细描述
出口参数
0 成功获得了所有的客户信息
-1 调用WebService异常
-2 调用WebService失败typedef struct tagDownDepInfo
{
char DPCODE1[6]; //一级部门
char DPCODE2[6]; //二级部门
char DPCODE3[8]; //三级部门
char DPCODE4[8]; //四级部门
char DPNAME1[60]; //
char DPNAME2[60]; //
char DPNAME3[60]; //
char DPNAME4[60]; //
}DOWNDEPINFO, FAR *PDOWNDEPINFO;
以上是dll里的函数说明及结构体我在delphi里调用。是这样写的type
PXinKaiPuDllDownDepInfo = ^TXinKaiPuDllDownDepInfo;
TXinKaiPuDllDownDepInfo = record
DPCODE1 : array[0..5] of char; //一级部门代码
DPCODE2 : array[0..5] of char; //二级部门代码
DPCODE3 : array[0..7] of char; //三级部门代码
DPCODE4 : array[0..7] of char; //四级部门代码
DPNAME1 : array[0..59] of char; //一级部门名称
DPNAME2 : array[0..59] of char; //二级部门名称
DPNAME3 : array[0..59] of char; //三级部门名称
DPNAME4 : array[0..59] of char; //四级部门名称
end;function XinKaiPuDll_CapGetDepList(A_pInfo: PXinKaiPuDllDownDepInfo): Integer; stdcall; New(pInfo);
FillChar(pInfo^,SizeOf(pInfo^),#0);
iRst2 := XinKaiPuDll_CapGetDepList(pInfo);
if iRst2 = 0 then
begin
for i := 0 to iRst1 - 1 do
begin
StrCopy(A_pInfo^[i].DPCODE1,pInfo^.DPCODE1);
StrCopy(A_pInfo^[i].DPNAME1,pInfo^.DPNAME1);
StrCopy(A_pInfo^[i].DPCODE2,pInfo^.DPCODE2);
StrCopy(A_pInfo^[i].DPNAME2,pInfo^.DPNAME2);
StrCopy(A_pInfo^[i].DPCODE3,pInfo^.DPCODE3);
StrCopy(A_pInfo^[i].DPNAME3,pInfo^.DPNAME3);
StrCopy(A_pInfo^[i].DPCODE4,pInfo^.DPCODE4);
StrCopy(A_pInfo^[i].DPNAME4,pInfo^.DPNAME4);
Inc(pInfo);
end;
Result := True;
end
else
begin
A_sRstMsg := XinKaiPuDll_ErrorMsg(iRst2);
end;
Dispose(pInfo);
long CapGetDepList(DOWNDEPINFO *pINFO)
6.11.1. 功能描述
得到所有的部门信息
6.11.2. 参数说明
入口参数
DOWNDEPINFO *pINFO 指向部门信息结构数组的指针,参见结构详细描述
出口参数
0 成功获得了所有的客户信息
-1 调用WebService异常
-2 调用WebService失败typedef struct tagDownDepInfo
{
char DPCODE1[6]; //一级部门
char DPCODE2[6]; //二级部门
char DPCODE3[8]; //三级部门
char DPCODE4[8]; //四级部门
char DPNAME1[60]; //
char DPNAME2[60]; //
char DPNAME3[60]; //
char DPNAME4[60]; //
}DOWNDEPINFO, FAR *PDOWNDEPINFO;
以上是dll里的函数说明及结构体我在delphi里调用。是这样写的type
PXinKaiPuDllDownDepInfo = ^TXinKaiPuDllDownDepInfo;
TXinKaiPuDllDownDepInfo = record
DPCODE1 : array[0..5] of char; //一级部门代码
DPCODE2 : array[0..5] of char; //二级部门代码
DPCODE3 : array[0..7] of char; //三级部门代码
DPCODE4 : array[0..7] of char; //四级部门代码
DPNAME1 : array[0..59] of char; //一级部门名称
DPNAME2 : array[0..59] of char; //二级部门名称
DPNAME3 : array[0..59] of char; //三级部门名称
DPNAME4 : array[0..59] of char; //四级部门名称
end;function XinKaiPuDll_CapGetDepList(A_pInfo: PXinKaiPuDllDownDepInfo): Integer; stdcall; New(pInfo);
FillChar(pInfo^,SizeOf(pInfo^),#0);
iRst2 := XinKaiPuDll_CapGetDepList(pInfo);
if iRst2 = 0 then
begin
for i := 0 to iRst1 - 1 do
begin
StrCopy(A_pInfo^[i].DPCODE1,pInfo^.DPCODE1);
StrCopy(A_pInfo^[i].DPNAME1,pInfo^.DPNAME1);
StrCopy(A_pInfo^[i].DPCODE2,pInfo^.DPCODE2);
StrCopy(A_pInfo^[i].DPNAME2,pInfo^.DPNAME2);
StrCopy(A_pInfo^[i].DPCODE3,pInfo^.DPCODE3);
StrCopy(A_pInfo^[i].DPNAME3,pInfo^.DPNAME3);
StrCopy(A_pInfo^[i].DPCODE4,pInfo^.DPCODE4);
StrCopy(A_pInfo^[i].DPNAME4,pInfo^.DPNAME4);
Inc(pInfo);
end;
Result := True;
end
else
begin
A_sRstMsg := XinKaiPuDll_ErrorMsg(iRst2);
end;
Dispose(pInfo);
memo1.Lines.add(pInfo^.DPCODE1[i]);
我觉得是共享内存有问题。delphi分配的指针或者空间或者是C++返回的地址之间的共享内存有问题。
但是我不知道该怎么解决。
我是在 DPCODE1 : array[0..5] of char; //一级部门代码
改成 DPCODE1 : array[0..6] of char; //一级部门代码
还是
StrCopy(A_pInfo^[i].DPCODE1,pInfo^.DPCODE1);
这个后边加什么?
将DPCODE1 : array[0..5] of char; //一级部门代码
改成 DPCODE1 : array[0..6] of char; //一级部门代码
不行
调用函数时,直接就报访问地址错误了。格式之间不对。肯定不行。
for i := 0 to iRst1 - 1 do
begin
iRst2 := XinKaiPuDll_CapGetDepList(@A_pInfo^[i]);
//...
end;
也可以吧。