我最近做了很多 PInvoke 的东西,想要靠近 Windows API 头文件。
在创建下面的枚举时,您会收到此编译器错误:
Error   1   Type byte, sbyte, short, ushort, int, uint, long, or ulong expected 
为什么 C# 编译器不理解任何其他基础类型?
C# 编译器可以从 uint 转到 System.UInt32,为什么不反过来呢?
using System;
using System.Runtime.InteropServices;
using DWORD = System.UInt32;
namespace BeSharp.Win32
{
    [StructLayout(LayoutKind.Sequential)]
    internal class MOUSEINPUT
    {
        // ...
        MouseData mouseData; // DWORD
        // ...
        [Flags]
        internal enum MouseData : System.UInt32; // needs to be uint; you cannot do DWORD or System.UInt32 here
        {
            Nothing = 0x0000,
            XBUTTON1 = 0x0001,
            XBUTTON2 = 0x0002,
        }
        // ...
    }
}