Possible duplicate:
SendInput and 64bit
I am using SendInput from .NET code (PInvoke). The code used to work on a 32-bit OS, but now on WIN7 SendInput returns 0, and the last error is set to 57 (ERROR_INVALID_PARAMETER).
I can not compile my code as x86, since I boot to a 64-bit host. In addition, I tried various solutions regarding the size of the structure and the field offsets, no one worked.
These are my imports and PInvoke types:
[StructLayout(LayoutKind.Sequential)]
struct KEYBOARD_INPUT
{
public uint type;
public ushort vk;
public ushort scanCode;
public uint flags;
public uint time;
public uint extrainfo;
public uint padding1;
public uint padding2;
}
[DllImport("User32.dll", SetLastError=true)]
private static extern uint SendInput(
uint numberOfInputs,
[MarshalAs(UnmanagedType.LPArray, SizeConst = 1)] KEYBOARD_INPUT[] input,
int structSize);
and code usage:
uint result = SendInput(
(uint)inputs.Count,
inputs.ToArray(),
Marshal.SizeOf(inputs[0]));
where the input array contains 1 KEYBOARD_INPUT struct.
this gives the result = 0, and when I check the last error, I get that the last error is set to 57 (ERROR_INVALID_PARAMETER, the parameter is incorrect).
64- 64- WIN7? XP...