D
denjin98
Unregistered / Unconfirmed
GUEST, unregistred user!
我在做DELPHI调VC的柜台中件间的DLL,好不容易过了连接中间件这一关,又遇到身份校验过不了,后面还有资金信息,股份信息,交割流水等,想学VC解又来不及,请各位高手帮助,请这方面的范例参考,最后VC涉及结构,联合,指针,数据类型,不胜感激!<br>附:客户身份校验有关代码:<br>VC:部份<br>typedef struct // 本结构中功能号(function)与操作方式(czfs)是必须的,其它可选 <br>{<br> unsigned short length; //长度 (整个数据包长度)<br> unsigned short crc ; //CRC校验码, 在单线程函数中,暂时没有使用的一致性<br> unsigned short serio; //序列号(按请求划分,从1开始)<br> unsigned char function; //功能号<br> unsigned char czfs; //操作方式(与柜台中的设置相同)<br> unsigned long status; //状态 0正确 其他错误(应答有效)<br>}tagBLOCK_HEAD;<br>typedef struct<br>{<br> tagBLOCK_HEAD HEAD; //头信息<br> char GDMS; // '2'同资金帐号关联(同资金帐号下的股东全部校验)<br> char KHBSLX; // 'Z' 资金帐号<br> char KHBS[CKBH_WIDTH]; //KHBS 股东代码或资金帐号或磁卡号<br> char JYMM[JYMM_WIDTH]; //JYMM 交易密码<br>}tagKHJY_Request;<br>typedef union<br>{<br> tagBLOCK_HEAD head;<br> tagKHJY_Request khjy;<br>}tagREQUEST;<br>int WINAPI KDAPI_Request(tagREQUEST &request);<br>void CAPI_TestDlg::OnButton1() <br>{<br> UpdateData();<br> <br> //身份校验<br> tagREQUEST g_Query;<br> tagRESULT g_Result;<br> memset(&g_Query,0,sizeof(g_Query));<br> g_Query.head.length = sizeof(g_Query.khjy);<br> g_Query.head.serio = 15;<br> g_Query.head.crc = 0;<br> g_Query.head.status = 0;<br> g_Query.head.function = funcKHJY;<br> g_Query.head.czfs = 2;<br> <br> g_Query.khjy.GDMS='2';<br> char s[20];<br> strcpy(s,m_strEdit_JYSDM);<br> g_Query.khjy.KHBSLX = s[0];<br> strcpy(g_Query.khjy.KHBS, m_strEdit_GDDM);<br> strcpy(g_Query.khjy.JYMM, m_strEdit_JYMM);<br> int iRet = KDAPI_Request(g_Query);<br> if (iRet < 0)<br> {<br> int iReturn = KDAPI_Answer(g_Result);<br> AfxMessageBox(g_Result.ErrMsg.ErrMsg);<br> long slll = g_Result.head.status;<br> }<br> else<br> {<br> AfxMessageBox("身份校验 成功! "<br> } <br>}<br>DELPHI部份:<br>type // 本结构中功能号(function)与操作方式(czfs)是必须的,其它可选<br> tagBLOCK_HEAD=record<br> length:Word; //长度 (整个数据包长度)<br> crc :Word; //CRC校验码, 在单线程函数中,暂时没有使用;<br> serio:Word; //序列号(按请求划分,从1开始)<br> funct:Byte;<br> czfs:Byte;<br> statusWORD;<br> end;<br>type<br> tagKHJY_Request=record<br> HEAD:tagBLOCK_HEAD; //头信息<br> GDMS:char; // '0'单股东(只校验单个股东代码的交易密码)<br> KHBSLX:char; // 'Z' 资金帐号<br> KHBS:array[1..CKBH_WIDTH-1] of char;<br> JYMM:array[1..JYMM_WIDTH-1] of char;<br> end;<br>type<br> tagREQUEST=record<br> khjy:tagKHJY_Request;<br>end;<br>g_Query:tagREQUEST;<br>function KDAPI_Request(requestointer): Integer; stdcall; external 'API_GT.dll';<br>g_Query.head.length:=sizeof(g_Query.khjy);<br> g_Query.head.serio:= 15;<br> g_Query.head.crc:= 0;<br> g_Query.head.status:= 0;<br> g_Query.head.funct:=funcKHJY;<br> g_Query.head.czfs:=2;<br> g_Query.khjy.GDMS:='2';<br> g_Query.khjy.KHBSLX:='Z';<br> for i:=0 to KHBS_WIDTH do<br> begin<br> g_Query.khjy.KHBS:=CHR(0);<br> end;<br> for i:=0 to KHBS_WIDTH do<br> begin<br> g_Query.khjy.KHBS:=KHBS;<br> end;<br> for i:=0 to JYMM_WIDTH DO <br> begin<br> g_Query.khjy.JYMM:=CHR(0);<br> end;<br> for i:=0 to JYMM_WIDTH DO <br> begin<br> g_Query.khjy.JYMM:=mm;<br> end;<br> g_Query.khjy.KHBSLX:='Z';<br>iRet:= KDAPI_Request(@g_Query); iret却-4(即其它错误)