【发布时间】:2014-06-27 09:42:26
【问题描述】:
我正在将 C 标头转换为 delphi 单元。我对UNION有疑问。 例如,在下面的例子中,(CASE INTEGER OF) 中应用的逻辑是什么? 这是转换这种结构的正确方法吗?
在 C 中
typedef union _FLT_PARAMETERS {
struct {
PIO_SECURITY_CONTEXT SecurityContext;
ULONG Options;
USHORT POINTER_ALIGNMENT FileAttributes;
USHORT ShareAccess;
ULONG POINTER_ALIGNMENT EaLength;
PVOID EaBuffer;
LARGE_INTEGER AllocationSize;
} Create;
struct {
PIO_SECURITY_CONTEXT SecurityContext;
ULONG Options;
USHORT POINTER_ALIGNMENT Reserved;
USHORT ShareAccess;
PVOID Parameters; // PNAMED_PIPE_CREATE_PARAMETERS
} CreatePipe;
...
在德尔福中
TCreate = record
SecurityContext: PIO_SECURITY_CONTEXT;
Options: ULONG;
FileAttributes: USHORT;
ShareAccess: USHORT;
EaLength: ULONG;
EaBuffer: PVOID;
AllocationSize: LARGE_INTEGER;
end;
TCreatePipe = Record
SecurityContext: PIO_SECURITY_CONTEXT;
Options: ULONG;
Reserved: USHORT;
ShareAccess: USHORT;
Parameters: PVOID;
end;
_FLT_PARAMETERS = Record
case integer of
0: (Create: TCreate);
1: (CreatePipe: TCreatePipe):
...
【问题讨论】:
标签: c delphi data-structures type-conversion