开发者

How to declare ULARGE_INTEGER in c#?

开发者 https://www.devze.com 2023-01-03 21:01 出处:网络
Based upon this question How to declarate LARGE_INTEGER in C# with answer of: [StructLayout(LayoutKind.Absolute, Size=8)]

Based upon this question How to declarate LARGE_INTEGER in C# with answer of:

[StructLayout(LayoutKind.Absolute, Size=8)]
struct LARGE_INTEGER
{
    [FieldOffset(0)]public Int64 QuadPart;
  开发者_如何学Python  [FieldOffset(0)]public UInt32 LowPart;
    [FieldOffset(4)]public Int32 HighPart;
}

Is my assumption below for declaring ULARGE_INTEGER correct?

[StructLayout(LayoutKind.Explicit, Size = 8)]
public struct ULARGE_INTEGER
{
    [FieldOffset(0)] public UInt64 QuadPart;
    [FieldOffset(0)] public UInt32 LowPart;
    [FieldOffset(4)] public UInt32 HighPart;
}


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消