我爲一個delphi單元轉換一個C頭。我對聯盟有懷疑。 例如,在下面的例子中,應用於(CASE INTEGER OF)的邏輯是什麼? 這是轉換此結構的正確方法嗎?將結構從C轉換爲Delphi
在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;
...
在Delphi
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):
...
我不清楚的是系統如何選擇案件中的選項。據我瞭解,就好像我有一個可以是TCreate或TCreatePipe的VARIANT類型。這是對的? – Flz
你瞭解工會的工作原理嗎?記錄的變體部分是相同的。我已經包含了文檔鏈接和摘錄。如果你向我展示了什麼'POINTER_ALIGNMENT',這也是非常有用的,所以我不必猜測。 –