如何在 C# 中声明 ULARGE_INTEGER?

发布于 2024-09-05 21:17:08 字数 886 浏览 7 评论 0 原文

基于这个问题 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;
}

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;
    [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;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寄居者 2024-09-12 21:17:08

它只是 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文