谁给我翻译下 简单的代码 CBuilder 翻译为 Delphi 6 主要是结构体问题(300分)

F

ftop1

Unregistered / Unconfirmed
GUEST, unregistred user!
typedef short apiStatus; // <br>struct &nbsp;TagIds<br>{<br> unsigned char TagType;<br> unsigned char AntNum;<br> unsigned char Ids[12];<br>};<br><br>extern "C" apiStatus &nbsp;__stdcall IsoMultiTagIdentify(HANDLE hCom, unsigned int * Count,TagIds *value, unsigned char ReaderAddr);//<br><br>///////////////////////////////////////////////////////////////////<br>void __fastcall TForm1::Timer1Timer(TObject *Sender)<br>{<br><br> if(IsoMultiTagIdentify(hComHandle,&amp;Cnt,IdBuf,0xff)==0)<br> {<br> mem-&gt;Lines-&gt;Add("读卡成功!!!");<br> <br> mem-&gt;Lines-&gt;Add(IntToStr(Cnt));<br> }<br><br>}
 
F

ftop1

Unregistered / Unconfirmed
GUEST, unregistred user!
以上是C Builder 的代码 我想要 Delphi 的
 
K

kkyy

Unregistered / Unconfirmed
GUEST, unregistred user!
type<br><br>apiStatus = WORD; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //short apiStatus; // <br><br>PTagIds = ^TagIds;<br>TagIds = record<br>&nbsp;TagType: Byte; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //unsigned char TagType;<br>&nbsp;AntNum: Byte; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//unsigned char AntNum;<br>&nbsp;Ids: array[0..11] of Byte; //unsigned char Ids[12];<br>end;<br><br>function IsoMultiTagIdentify(hCom: THandle; Count: PDWORD; value: PTagIds; ReaderAddr: Byte): apiStatus; stdcall; <br>//外部函数,要链接到相应的OBJ,或者链接到相应OBJ编译的导出DLL<br>//extern "C" apiStatus &nbsp;__stdcall IsoMultiTagIdentify(HANDLE hCom, unsigned int * Count,TagIds *value, unsigned char ReaderAddr);//<br><br>implementation<br><br>procedure TForm1::Timer1Timer(TObject *Sender);<br>begin<br>&nbsp; &nbsp;if IsoMultiTagIdentify(hComHandle, @Cnt, PTagIds(IdBuf), $FF) = 0 then begin<br>&nbsp; &nbsp; &nbsp; mem.Lines.Add('读卡成功!!!');<br>&nbsp; &nbsp; &nbsp; mem.Lines.Add(IntToStr(Cnt));<br>&nbsp; &nbsp;end;<br>end;<br><br>大体是这样, 自己验证吧...
 
W

wr960204

Unregistered / Unconfirmed
GUEST, unregistred user!
楼上翻译的是正确的.<br>也可以这样翻译.那几个指针参数都是要传入非空的,然后要在里面传出结果的.可以翻译成传递引用.<br>type<br>&nbsp; apiStatus = WORD;<br>&nbsp; TagIds = record<br>&nbsp; &nbsp; TagType : Byte;<br>&nbsp; &nbsp; AntNum : Byte;<br>&nbsp; &nbsp; Ids: array[0..12-1] of Byte;<br>&nbsp; end; <br>&nbsp; lpTagIds = ^TagIds;<br><br>function IsoMultiTagIdentify(hCom: DWORD; var Count: DWORD; var value : TagIds; &nbsp;ReaderAddr : Byte):apiStatus; stdcall; external '你的DLL文件.DLL';<br>&nbsp;<br>&nbsp;<br>procedure TForm1.Timer1Timer(Sender : TObject);<br>begin<br><br>&nbsp; if(IsoMultiTagIdentify(hComHandle,Cnt,IdBuf^,$ff)=0) then<br>&nbsp; begin<br>&nbsp; &nbsp;mem.Lines.Add('读卡成功!!!');<br>&nbsp; &nbsp;<br>&nbsp; &nbsp;mem.Lines.Add(IntToStr(Cnt));<br>&nbsp; end;<br><br>end;
 
F

ftop1

Unregistered / Unconfirmed
GUEST, unregistred user!
接受答案了.
 
顶部