vc中strcut类型在delphi中调用的问题(100分)

  • 主题发起人 主题发起人 letgolxh
  • 开始时间 开始时间
L

letgolxh

Unregistered / Unconfirmed
GUEST, unregistred user!
vc是这样定义的<br>typedef struct lxh {<br> char cx1[1]; // 区域0 密文数据(84字节),密文共4行,每行21个字母<br> char cx2[1]; // 区域8 加密版本号(2字节)<br> char cx3[1]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 区域1 发票代码(10字节)<br>} lxhDATA, *lxhPINDATA;<br><br>int WINAPI Hellolxh(lxh lxhData)<br>{<br>MessageBox(NULL,lxhData.cx1,lxhData.cx1,0) ;<br>MessageBox(NULL,lxhData.cx2,lxhData.cx2,0) ;<br>MessageBox(NULL,lxhData.cx3,lxhData.cx3,0) ;<br>&nbsp;return 100 ;<br>}<br><br>在delphi中定义<br>&nbsp; &nbsp;lxh = record<br>&nbsp; &nbsp; &nbsp; &nbsp;CX1 :array [0..0] of pchar ;<br>&nbsp; &nbsp; &nbsp; &nbsp;CX2 :array [0..0] of pchar ;<br>&nbsp; &nbsp; &nbsp; &nbsp;CX3 :array [0..0] of pchar;<br>&nbsp; &nbsp; &nbsp; &nbsp;END;<br>&nbsp; &nbsp; lxhPINDATA = ^lxh ;<br><br>调用<br>procedure Tfrm_query.Button2Click(Sender: TObject);<br>var ab :lxh ;<br>lxhPINDATA : ^lxh ;<br>begin<br>ab.CX1[0] := 'a' ;<br>ab.CX2[0] := 'b' ;<br>ab.CX3[0] := 'c' ;<br>Hellolxh(@ab) ;<br>end;<br>不会报错,但是msgbox显示的是乱码??<br>为什么?<br><br>
 
试试看<br><br>lxh = record<br>&nbsp; &nbsp; &nbsp; &nbsp;CX1 : pchar ;<br>&nbsp; &nbsp; &nbsp; &nbsp;CX2 : pchar ;<br>&nbsp; &nbsp; &nbsp; &nbsp;CX3 : pchar;<br>&nbsp; &nbsp; &nbsp; &nbsp;END;<br>&nbsp; &nbsp; lxhPINDATA = ^lxh ;<br><br>还有<br>int WINAPI Hellolxh(lxh lxhData)<br>传的不是指针吧
 
c中的字串需要有0结尾
 
后退
顶部