如何在 C# 中声明 ULARGE_INTEGER?
基于这个问题 How to declarate LARGE_INTEGER in C# with 答案:
[StructLayout(LayoutKind.Absolute, Size=8)]
struct LARGE_INTEGER
{
[FieldOffset(0)]public Int64 QuadPart;
[FieldOffset(0)]public UInt32 LowPart;
[FieldOffset(4)]public Int32 HighPart;
}
以下是我对声明ULARGE_INTEGER
正确吗?
[StructLayout(LayoutKind.Explicit, Size = 8)]
public struct ULARGE_INTEGER
{
[FieldOffset(0)] public UInt64 QuadPart;
[FieldOffset(0)] public UInt32 LowPart;
[FieldOffset(4)] public UInt32 HighPart;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它只是 C# 中的一个 ulong,无需跳过 LayoutKind.Explicit 环。该联合是必要的,因为 C 和 C++ 编译器在过去没有本机 64 位类型。
It is simply an ulong in C#, no need to jump through the LayoutKind.Explicit hoop. The union was necessary because C and C++ compilers didn't have a native 64-bit type in the olden days.