A
aq100
Unregistered / Unconfirmed
GUEST, unregistred user!
原C++代码typedef struct tagRCV_REPORT { WORD m_cbSize; char m_szName[32]; } RCV_REPORT;typedef struct tagRCV_DATA{ int m_nPacketNum; union { RCV_REPORT* m_pReport; void * m_pData; };} RCV_DATA;LONG OnDataRec(UINT wParam,LONG lParam){ RCV_DATA * pHeader; pHeader = (RCV_DATA *)lParam; switch( wParam ) { case RCV_DATA: for(i=0
i<pHeader->m_nPacketNum
i++) { CString jc=pHeader->m_pReport.m_szName; } break; }}翻译后的Delphi代码RCV_REPORT = packed record m_cbSize:word
m_strName: array[0..31]of char
end;PRCV_REPORT=RCV_REPORT;RCV_DATA =packed record m_nPacketNum:Integer; case Integer of 0: (m_pReportRCV_REPORT
1: (m_pDataointer;end;PRCV_DATA=^RCV_DATA
procedure TForm1.OnDataRec(var msg : TMessage);var pHeaderRCV_DATA
i:integer
strTemp:String;begin case msg.WParam of RCV_DATA: begin pHeader:=PRCV_DATA(msg.LParam)
for i:=0 to pHeader.m_nPacketNum-1 do begin HexString:=''
HexString:=HexString+pHeader^.m_pReport.m_szName
{关键是底下这句,好像没起什么作用,出来的数据不对} inc(pHeader^.m_pReport)
end
end
end;inherited;end;编译执行都没问题,就是数据不对。怀疑inc(pHeader^.m_pReport);有问题,希望兄弟们指点迷津。300分以示谢意,不够可以再发300分。
i<pHeader->m_nPacketNum
i++) { CString jc=pHeader->m_pReport.m_szName; } break; }}翻译后的Delphi代码RCV_REPORT = packed record m_cbSize:word
m_strName: array[0..31]of char
end;PRCV_REPORT=RCV_REPORT;RCV_DATA =packed record m_nPacketNum:Integer; case Integer of 0: (m_pReportRCV_REPORT
1: (m_pDataointer;end;PRCV_DATA=^RCV_DATA
procedure TForm1.OnDataRec(var msg : TMessage);var pHeaderRCV_DATA
i:integer
strTemp:String;begin case msg.WParam of RCV_DATA: begin pHeader:=PRCV_DATA(msg.LParam)
for i:=0 to pHeader.m_nPacketNum-1 do begin HexString:=''
HexString:=HexString+pHeader^.m_pReport.m_szName
{关键是底下这句,好像没起什么作用,出来的数据不对} inc(pHeader^.m_pReport)
end
end
end;inherited;end;编译执行都没问题,就是数据不对。怀疑inc(pHeader^.m_pReport);有问题,希望兄弟们指点迷津。300分以示谢意,不够可以再发300分。