1

I have try to use Raw Input from this http://www.codeproject.com/Articles/17123/Using-Raw-Input-from-C-to-handle-multiple-keyboard

I develop on windows 7 64 bit with .net 4.0 and Visual Studio 2010 it work perfectly in windows 7 but after I test the program on windows XP service pack 3 32&64 bit, it cannot register input device. It might be some mistake at this step for Windows XP but in Windows 7 it work well.

    if(!Win32.RegisterRawInputDevices(rid, (uint)rid.Length, (uint)Marshal.SizeOf(rid[0])))
    {
        throw new ApplicationException("Failed to register raw input device(s).");
    }

in Win32 import User32.dll like this

[DllImport("User32.dll", SetLastError = true)]
internal static extern bool RegisterRawInputDevices(RawInputDevice[] pRawInputDevice, uint numberDevices, uint size);

How can I make it work with windows XP.

MAXZZXAM
  • 67
  • 7
  • 1
    For starters, you could try reading the error message you get back. – Mark Jansen Nov 19 '15 at 09:54
  • I have try but the program wasn't error it just alway return false in this 'Win32.RegisterRawInputDevices(rid, (uint)rid.Length, (uint)Marshal.SizeOf(rid[0]))' ,I am not sure about imoort `User32.dll` it will work the same with **Windows XP** – MAXZZXAM Nov 19 '15 at 10:30
  • http://stackoverflow.com/a/1650868/2715716 Check what this returns. – Tomáš Hübelbauer Nov 19 '15 at 10:41
  • I try by add like this `if(!Win32.RegisterRawInputDevices(rid, (uint)rid.Length, (uint)Marshal.SizeOf(rid[0]))) { string errorMessage = new Win32Exception(Marshal.GetLastWin32Error()).Message; System.Windows.Forms.MessageBox.Show(errorMessage); throw new ApplicationException("Failed to register raw input device(s)."); }` but it alert only "Invalid flags" – MAXZZXAM Nov 19 '15 at 12:01
  • I am wondering if you found a solution for that problem, I am facing same behavior on Win XP. Windows 7 and up works great. Thanks! – Michael Parshin Nov 23 '16 at 18:01

0 Answers0