N
not_a_commie
I've been using INPUT as declared below. However, I get warnings about
this being incompatible with a 64bit OS. I have no 64bit OS to test
on. However, is it true that the union in the INPUT declaration below
would need to line on an 8byte boundary for a 64bit OS? And should I
just do this with #if? #if 64bitosblah FieldOffset(8) #else
FieldOffset(4)?
[DllImport("User32.dll", SetLastError = true)]
public static extern uint SendInput(uint nInputs, INPUT[] pInputs,
int cbSize);
[StructLayout(LayoutKind.Sequential)]
public struct MOUSEINPUT
{
public int dx;
public int dy;
public uint mouseData;
public uint dwFlags;
public uint time;
public IntPtr dwExtraInfo;
}
[StructLayout(LayoutKind.Sequential)]
public struct KEYBDINPUT
{
public ushort wVk;
public ushort wScan;
public uint dwFlags;
public uint time;
public IntPtr dwExtraInfo;
}
[StructLayout(LayoutKind.Sequential)]
public struct HARDWAREINPUT
{
public uint uMsg;
public ushort wParamL;
public ushort wParamH;
}
[StructLayout(LayoutKind.Explicit)]
public struct INPUT
{
[FieldOffset(0)]
public int type;
[FieldOffset(4)]
public MOUSEINPUT mi;
[FieldOffset(4)]
public KEYBDINPUT ki;
[FieldOffset(4)]
public HARDWAREINPUT hi;
}
this being incompatible with a 64bit OS. I have no 64bit OS to test
on. However, is it true that the union in the INPUT declaration below
would need to line on an 8byte boundary for a 64bit OS? And should I
just do this with #if? #if 64bitosblah FieldOffset(8) #else
FieldOffset(4)?
[DllImport("User32.dll", SetLastError = true)]
public static extern uint SendInput(uint nInputs, INPUT[] pInputs,
int cbSize);
[StructLayout(LayoutKind.Sequential)]
public struct MOUSEINPUT
{
public int dx;
public int dy;
public uint mouseData;
public uint dwFlags;
public uint time;
public IntPtr dwExtraInfo;
}
[StructLayout(LayoutKind.Sequential)]
public struct KEYBDINPUT
{
public ushort wVk;
public ushort wScan;
public uint dwFlags;
public uint time;
public IntPtr dwExtraInfo;
}
[StructLayout(LayoutKind.Sequential)]
public struct HARDWAREINPUT
{
public uint uMsg;
public ushort wParamL;
public ushort wParamH;
}
[StructLayout(LayoutKind.Explicit)]
public struct INPUT
{
[FieldOffset(0)]
public int type;
[FieldOffset(4)]
public MOUSEINPUT mi;
[FieldOffset(4)]
public KEYBDINPUT ki;
[FieldOffset(4)]
public HARDWAREINPUT hi;
}