1

私は最近、Windows API ヘッダー ファイルの近くにとどまりたいと思って、かなりの数の PInvoke を行ってきました。

以下の列挙型を作成すると、次のコンパイラ エラーが発生します。

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,
        }
        // ...
    }
}
4

0 に答える 0