结构体转换(100分)

  • 主题发起人 snowvalley
  • 开始时间
S

snowvalley

Unregistered / Unconfirmed
GUEST, unregistred user!
请问如何转换如下C结构体和共享体到Delphi机构体和共享体?谢谢!
struct __PACKET_BUFFER__
{
BYTE Status;
BYTE AclType;
BYTE NetType;
BYTE TimeType;
ULONG AclId;
union
{
struct
{
USHORT TcpCode : 6;
USHORT Reserved : 10;
};
struct
{
USHORT TcpFin : 1;
USHORT TcpSyn : 1;
USHORT TcpRst : 1;
USHORT TcpPsh : 1;
USHORT TcpAck : 1;
USHORT TcpUrg : 1;
USHORT Direction : 1; // 0: IN, 1: OUT
USHORT SendOrRecv : 1;
USHORT Action : 8;
};
};
BYTE bReserved[2];
BYTE Protocol;
BYTE Week;
BYTE IcmpType;
BYTE IcmpSubType;
ULONG Time;
ULONG SourceIp;
ULONG DestinationIp;
union
{
ULONG Id;
struct
{
ULONG SourcePort : 16;
ULONG DestinationPort : 16;
};
};
ULONG DataBytes;
ULONG ProcessHandle;
char sProcess[16];
};
///////////////////////////////////////////////////////////////////////////////[:)]
struct __PACKET_DIRECTION__
{
ULONG Id;
struct
{
BYTE Direction : 4;
BYTE Action : 4;
};
BYTE NetType;
struct
{
BYTE AclType : 4;
BYTE Reserved : 2;
BYTE DeleteIn : 1;
BYTE DeleteOut: 1;
};
BYTE Protocol;
ULONG AclId;
ULONG Time;
ULONG ProcessHandle;
ULONG SendData;
ULONG RecvData;
ULONG LocalIp;
ULONG RemoteIp;
USHORT LocalPort;
USHORT RemotePort;
char sProcess[16];
};
 
我不是在CSDN说了吗?
我只是跟你提个方法。。。。
那咱们看看还有其它什么好方法没。。。
 
具体一点可以吗?
 
因为这个已经困惑我很久了.
 
Pascal语言中的记录类型,相当于C语言中的结构体;在记录类型中加入可变部分,则可以相当于
C语言中的共用体
上面的C语言大致可以这样翻译:
type
__PACKET_BUFFER__ = record
Status : BYTE ;
......
......
end;
你最好还是找一本Object Pascal语法书看看吧,我现在也是初学,大家一起进步吧[:)]
 
多人接受答案了。
 

Similar threads

I
回复
0
查看
630
import
I
I
回复
0
查看
735
import
I
I
回复
0
查看
824
import
I
I
回复
0
查看
937
import
I
顶部