gpt4 book ai didi

delphi - 德尔福的 C 联盟

转载 作者:行者123 更新时间:2023-12-03 18:21:26 25 4
gpt4 key购买 nike

我想翻译 winnt.h 中的一些类型定义,其中包含一些与位域的联合。然而,这是正确的做法吗?我特别不确定 _TP_CALLBACK_ENVIRON_V3 中的联合。

  typedef struct _UMS_SYSTEM_THREAD_INFORMATION {
ULONG UmsVersion;
union {
struct {
ULONG IsUmsSchedulerThread : 1;
ULONG IsUmsWorkerThread : 1;
} DUMMYSTRUCTNAME;
ULONG ThreadUmsFlags;
} DUMMYUNIONNAME;
} UMS_SYSTEM_THREAD_INFORMATION, *PUMS_SYSTEM_THREAD_INFORMATION;

typedef struct _TP_CALLBACK_ENVIRON_V3 {
TP_VERSION Version;
PTP_POOL Pool;
PTP_CLEANUP_GROUP CleanupGroup;
PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback;
PVOID RaceDll;
struct _ACTIVATION_CONTEXT *ActivationContext;
PTP_SIMPLE_CALLBACK FinalizationCallback;
union {
DWORD Flags;
struct {
DWORD LongFunction : 1;
DWORD Persistent : 1;
DWORD Private : 30;
} s;
} u;
TP_CALLBACK_PRIORITY CallbackPriority;
DWORD Size;
} TP_CALLBACK_ENVIRON_V3;

type
UMS_SYSTEM_THREAD_INFORMATION = record
UmsVersion: ULONG;
ThreadUmsFlags: ULONG;
case Integer of
0:(IsUmsSchedulerThread : ULONG);
1:(IsUmsWorkerThread : ULONG);
end;
PUMS_SYSTEM_THREAD_INFORMATION = ^UMS_SYSTEM_THREAD_INFORMATION;

TP_CALLBACK_ENVIRON_V3 = record
Version: TP_VERSION;
Pool: PTP_POOL;
CleanupGroup: PTP_CLEANUP_GROUP;
CleanupGroupCancelCallback: PTP_CLEANUP_GROUP_CANCEL_CALLBACK;
RaceDll: PVOID;
ActivationContext: PACTIVATION_CONTEXT; // Pointer
FinalizationCallback: PTP_SIMPLE_CALLBACK;
case Flags: DWORD of
1: (LongFunction: DWORD)
1: (Persistent: DWORD)
30: (Private: DWORD)
end;
CallbackPriority: TP_CALLBACK_PRIORITY;
Size: DWORD;
end;
PTP_CALLBACK_ENVIRON = ^TP_CALLBACK_ENVIRON_V3;

最佳答案

那些 : Something 符号是位字段。没有直接的 Pascal 等价物。

但是,由于三个位域组合起来是一个完整的双字,因此等效项的总体轮廓如下所示:

type
_TP_CALLBACK_ENVIRON_V3 = record
...
FinalizationCallback: PTP_SIMPLE_CALLBACK;
case Integer of
1: (Flags: DWord);
2: (LongFunctionPersistentPrivate: DWord)
end;

关于delphi - 德尔福的 C 联盟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27735676/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com