两条语句:C++翻译为delphi。等于白送分,来看看吧(在线等候)。受不了啦!!每人理!! (100分)

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

DZHZH2000

Unregistered / Unconfirmed
GUEST, unregistred user!
typedef struct _rcv_msg<br>{<br> int SerialNO;<br> char AlarmDate[20];<br> char AlarmTime[20];<br> <br> int AlarmType;<br><br> int AlarmCH;<br> char AlarmContent[100];<br> <br>} RCV_MSG;<br><br>typedef struct _snd_msg<br>{<br> int SerialNO;<br> int AlarmType;<br> int targetType;<br> char targetNO[20];<br> int CtrlCH;<br> char CtrlContent[100];<br> <br>} SND_MSG;<br><br>以下两句请翻译成delphi的语句:<br>extern BOOL APIENTRY PackCommandInfo( SND_MSG *sndmsg, char *cmd &nbsp;);<br>extern BOOL APIENTRY AnalyeAlarmInfo( char *msg, RCV_MSG *rcvmsg );<br>
 
高手呢?怎么每人回答?5555555555555555
 
type<br>&nbsp; &nbsp; pRCV_MSG = _rcv_msg^<br>&nbsp; &nbsp; _rcv_msg = record<br>&nbsp; &nbsp; &nbsp; &nbsp;SerialNO &nbsp; &nbsp;: integer;<br>&nbsp; &nbsp; &nbsp; &nbsp;AlarmDate,<br>&nbsp; &nbsp; &nbsp; &nbsp;AlarmTime &nbsp; : array[0..19] of char;<br>&nbsp; &nbsp; &nbsp; &nbsp;AlarmType,<br>&nbsp; &nbsp; &nbsp; &nbsp;AlarmCH &nbsp; &nbsp; : integer;<br>&nbsp; &nbsp; &nbsp; &nbsp;AlarmContent: array[0..99] of char;<br>&nbsp; &nbsp; end;<br>&nbsp;<br>&nbsp; &nbsp; pSND_MSG = _snd_msg^<br>&nbsp; &nbsp; _snd_msg = record<br>&nbsp; &nbsp; &nbsp; &nbsp;SerialNO &nbsp; &nbsp;: integer;<br>&nbsp; &nbsp; &nbsp; &nbsp;AlarmType,<br>&nbsp; &nbsp; &nbsp; &nbsp;targetType &nbsp;: integer;<br>&nbsp; &nbsp; &nbsp; &nbsp;targetNO &nbsp; &nbsp;: array[0..19] of char;<br>&nbsp; &nbsp; &nbsp; &nbsp;CtrlCH &nbsp; &nbsp; &nbsp;: integer;<br>&nbsp; &nbsp; &nbsp; &nbsp;CtrlContent : array[0..99] of char;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; function PackCommandInfo(sndmsg : pSND_MSG, cmd : PChar ): boolean;<br>&nbsp; &nbsp; function AnalyeAlarmInfo(msg : PChar, rcvmsg : pRCV_MSG ): boolean;<br>
 
to kkyy:<br>&nbsp; 你的答案编译通不过。<br>&nbsp; 再说明一下:<br>&nbsp; extern BOOL APIENTRY PackCommandInfo( SND_MSG *sndmsg, char *cmd &nbsp;);<br>&nbsp; extern BOOL APIENTRY AnalyeAlarmInfo( char *msg, RCV_MSG *rcvmsg );<br>&nbsp; 这两句是声明外部dll函数的。<br>
 
&nbsp;_rcv_msg = record<br> SerialNO:integer;<br> AlarmDate,AlarmTime:Array [0..19] of char;<br> AlarmType,AlarmCH:integer;<br> AlarmContent:Array [0..99] of char;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; _snd_msg = record<br> SerialNO,AlarmType,targetType:integer;<br> targetNO:Array [0..19] of char;<br> CtrlCH:integer;<br> CtrlContent:Array [0..99] of char;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; pRCV_MSG = ^_rcv_msg;<br>&nbsp; pSND_MSG = ^_snd_msg;<br><br>&nbsp; function PackCommandInfo( sndmsg:pSND_MSG;cmd:pchar ):BOOL;stdcall;external 'TEST.DLL'<br>&nbsp; function AnalyeAlarmInfo( msg:pchar;rcvmsg:pRCV_MSG ):BOOL;stdcall;external 'TEST.DLL'<br>其中test.dll换成呢自己Dll的名字
 
请问zhhc,我这样对不对?<br>type TRCV_MSG = record<br>&nbsp; &nbsp; SerialNO: integer;<br>&nbsp; &nbsp; AlarmDate: array[0..20] of char;<br>&nbsp; &nbsp; AlarmTime: array[0..20] of char;<br>&nbsp; &nbsp; AlarmType: integer;<br>&nbsp; &nbsp; AlarmCH: integer;<br>&nbsp; &nbsp; AlarmContent: array[0..100] of char;<br>&nbsp; end;<br><br><br>type TSND_MSG = record<br>&nbsp; &nbsp; SerialNO: integer;<br>&nbsp; &nbsp; AlarmType: integer;<br>&nbsp; &nbsp; targetType: integer;<br>&nbsp; &nbsp; targetNO: array[0..20] of char;<br>&nbsp; &nbsp; CtrlCH: integer;<br>&nbsp; &nbsp; CtrlContent: array[0..100] of char;<br>&nbsp; end;<br><br>function AnalyeAlarmInfo(var msg: Char; var rcvmsg: TRCV_MSG): boolean; Stdcall; external 'GisAPI.dll';<br>function PackCommandInfo(var sndmsg: TSND_MSG; var cmd: char): boolean; Stdcall; external 'GisAPI.dll';<br>
 
用var可能不妥吧,<br>因为Delphi的var型变量和C的指针好像还是有点区别的,不过我也没试过。<br>不过var char 肯定和pchar不同,这个是不能替换的<br>最好还是像我一样,用指针。<br><br>再就是在上面的几个数组的下标都要减1,或者把上标加1,就像我定义的一样,否则肯定是错的。<br>
 
我知道是外部啊呀<br>extern BOOL APIENTRY说明了是外部,不过你在BCB中是有LIB可以加入,这里我又不知道你是什么DLL。呵呵。。<br>你自己加了。
 
给分了kkyy:=30;zhhc:=70
 
多人接受答案了。
 
顶部