以下的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];
};
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];
};
struct
{
BYTE Direction : 4;
BYTE Action : 4;
};的结构定义在Delphi中可以使用掩码移位的方式解决,或定义一个类,内部使用结构,外部使用属性然后作转换
struct CStruct{
int x;
union{
int y;
int z;
}
}
// d
TStruct = record
x: Integer;
case Integer of
0: (y: Integer);
1: (z: Integer);
end;