哪位高手做过DELPHI调VC DLL的,请给个例子示范下,VC DLL传值将我折腾得够呛!(17分)

  • 主题发起人 主题发起人 denjin98
  • 开始时间 开始时间
D

denjin98

Unregistered / Unconfirmed
GUEST, unregistred user!
我在做DELPHI调VC的柜台中件间的DLL,好不容易过了连接中间件这一关,又遇到身份校验过不了,后面还有资金信息,股份信息,交割流水等,想学VC解又来不及,请各位高手帮助,请这方面的范例参考,最后VC涉及结构,联合,指针,数据类型,不胜感激!<br>附:客户身份校验有关代码:<br>VC:部份<br>typedef struct &nbsp;// 本结构中功能号(function)与操作方式(czfs)是必须的,其它可选 <br>{<br> &nbsp;unsigned short length; &nbsp; &nbsp; &nbsp; //长度 &nbsp;(整个数据包长度)<br> &nbsp;unsigned short crc ; &nbsp; &nbsp; &nbsp; &nbsp; //CRC校验码, 在单线程函数中,暂时没有使用的一致性<br> &nbsp;unsigned short serio; &nbsp; &nbsp; &nbsp; &nbsp;//序列号(按请求划分,从1开始)<br> &nbsp;unsigned char function; &nbsp; &nbsp; &nbsp;//功能号<br> &nbsp;unsigned char czfs; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//操作方式(与柜台中的设置相同)<br> &nbsp;unsigned long status; &nbsp; &nbsp; &nbsp; &nbsp;//状态 0正确 其他错误(应答有效)<br>}tagBLOCK_HEAD;<br>typedef struct<br>{<br> &nbsp;tagBLOCK_HEAD HEAD; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//头信息<br> &nbsp;char GDMS; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// '2'同资金帐号关联(同资金帐号下的股东全部校验)<br> &nbsp;char KHBSLX; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// 'Z' 资金帐号<br> &nbsp;char KHBS[CKBH_WIDTH]; &nbsp; &nbsp; &nbsp; //KHBS &nbsp;股东代码或资金帐号或磁卡号<br> &nbsp;char JYMM[JYMM_WIDTH]; &nbsp; &nbsp; &nbsp; //JYMM &nbsp;交易密码<br>}tagKHJY_Request;<br>typedef union<br>{<br> &nbsp;tagBLOCK_HEAD head;<br> &nbsp;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 &lt; 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(&quot;身份校验 成功! &quot;);<br> } <br>}<br>DELPHI部份:<br>type &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 本结构中功能号(function)与操作方式(czfs)是必须的,其它可选<br> &nbsp;tagBLOCK_HEAD=record<br> &nbsp; length:Word; &nbsp; &nbsp; &nbsp; //长度 &nbsp;(整个数据包长度)<br> &nbsp; crc :Word; &nbsp; &nbsp; &nbsp; &nbsp; //CRC校验码, 在单线程函数中,暂时没有使用;<br> &nbsp; serio:Word; &nbsp; &nbsp; &nbsp; &nbsp;//序列号(按请求划分,从1开始)<br> &nbsp; funct:Byte;<br> &nbsp; czfs:Byte;<br> &nbsp; status:DWORD;<br> &nbsp;end;<br>type<br> &nbsp;tagKHJY_Request=record<br> &nbsp;HEAD:tagBLOCK_HEAD; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//头信息<br> &nbsp;GDMS:char; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // '0'单股东(只校验单个股东代码的交易密码)<br> &nbsp;KHBSLX:char; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// 'Z' 资金帐号<br> &nbsp;KHBS:array[1..CKBH_WIDTH-1] of char;<br> JYMM:array[1..JYMM_WIDTH-1] of char;<br> &nbsp;end;<br>type<br> &nbsp;tagREQUEST=record<br> &nbsp;khjy:tagKHJY_Request;<br>end;<br>g_Query:tagREQUEST;<br>function KDAPI_Request(request:Pointer): 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> &nbsp;for i:=0 to &nbsp;KHBS_WIDTH do<br> &nbsp;begin<br> &nbsp;g_Query.khjy.KHBS:=CHR(0);<br> &nbsp;end;<br> &nbsp;for i:=0 to &nbsp;KHBS_WIDTH do<br> &nbsp;begin<br> &nbsp;g_Query.khjy.KHBS:=KHBS;<br> &nbsp;end;<br> &nbsp;for i:=0 to JYMM_WIDTH &nbsp; DO <br> &nbsp;begin<br> &nbsp;g_Query.khjy.JYMM:=CHR(0);<br> &nbsp;end;<br> &nbsp;for i:=0 to JYMM_WIDTH &nbsp; DO <br> &nbsp;begin<br> &nbsp;g_Query.khjy.JYMM:=mm;<br> &nbsp;end;<br> &nbsp;g_Query.khjy.KHBSLX:='Z';<br>iRet:= KDAPI_Request(@g_Query); &nbsp; iret却-4(即其它错误)
 
如果有VC的源代码工程,加载Delphi 的EXE .可以调试一下看看,错误出在哪里!
 
楼主的 &nbsp;&quot;柜台中件间的DLL&quot; &nbsp; 是哪里的.?<br><br>可否发资料给我看看??
 
后退
顶部