title: GetRawInputDeviceList not working as expected on Windows7
body: <p>I ran into the following problem: Using GetRawInputDeviceList in C# or C++ produces different results in Win8 vs Win7. I took a C++ example ran it in Win8 and did get appropriate results where it did not in Win7 latest patch level.
  So I took an old Win7 image (no patches applied) and ran the example against it - and it produced expected results. </p>
  
  <pre><code>        // ConsoleApplication2.cpp : Defines the entry point for the console application.
      //
  
      #include "stdafx.h"
      #include &lt;windows.h&gt;
      #include &lt;iostream&gt;
  
      // Namespace
      using namespace std;
  
      // Main
      int main()
      {
        // Program
        cout &lt;&lt; "USB Device Lister." &lt;&lt; endl;
  
        // Get Number Of Devices
        UINT nDevices = 0;
        GetRawInputDeviceList(NULL, &amp;nDevices, sizeof(RAWINPUTDEVICELIST));
  
        // Got Any?
        if (nDevices &lt; 1)
        {
          // Exit
          cout &lt;&lt; "ERR: 0 Devices?";
          cin.get();
          return 0;
        }
  
        // Allocate Memory For Device List
        PRAWINPUTDEVICELIST pRawInputDeviceList;
        pRawInputDeviceList = new RAWINPUTDEVICELIST[sizeof(RAWINPUTDEVICELIST)* nDevices];
  
        // Got Memory?
        if (pRawInputDeviceList == NULL)
        {
          // Error
          cout &lt;&lt; "ERR: Could not allocate memory for Device List.";
          cin.get();
          return 0;
        }
  
        // Fill Device List Buffer
        int nResult;
        nResult = GetRawInputDeviceList(pRawInputDeviceList, &amp;nDevices, sizeof(RAWINPUTDEVICELIST));
  
        // Got Device List?
        if (nResult &lt; 0)
        {
          // Clean Up
          delete[] pRawInputDeviceList;
  
          // Error
          cout &lt;&lt; "ERR: Could not get device list.";
          cin.get();
          return 0;
        }
  
        // Loop Through Device List
        for (UINT i = 0; i &lt; nDevices; i++)
        {
          // Get Character Count For Device Name
          UINT nBufferSize = 0;
          nResult = GetRawInputDeviceInfo(pRawInputDeviceList[i].hDevice, // Device
            RIDI_DEVICENAME,                // Get Device Name
            NULL,                           // NO Buff, Want Count!
            &amp;nBufferSize);                 // Char Count Here!
  
          // Got Device Name?
          if (nResult &lt; 0)
          {
            // Error
            cout &lt;&lt; "ERR: Unable to get Device Name character count.. Moving to next device." &lt;&lt; endl &lt;&lt; endl;
  
            // Next
            continue;
          }
  
          // Allocate Memory For Device Name
          WCHAR* wcDeviceName = new WCHAR[nBufferSize + 1];
  
          // Got Memory
          if (wcDeviceName == NULL)
          {
            // Error
            cout &lt;&lt; "ERR: Unable to allocate memory for Device Name.. Moving to next device." &lt;&lt; endl &lt;&lt; endl;
  
            // Next
            continue;
          }
  
          // Get Name
          nResult = GetRawInputDeviceInfo(pRawInputDeviceList[i].hDevice, // Device
            RIDI_DEVICENAME,                // Get Device Name
            wcDeviceName,                   // Get Name!
            &amp;nBufferSize);                 // Char Count
  
          // Got Device Name?
          if (nResult &lt; 0)
          {
            // Error
            cout &lt;&lt; "ERR: Unable to get Device Name.. Moving to next device." &lt;&lt; endl &lt;&lt; endl;
  
            // Clean Up
            delete[] wcDeviceName;
  
            // Next
            continue;
          }
  
          // Set Device Info &amp; Buffer Size
          RID_DEVICE_INFO rdiDeviceInfo;
          rdiDeviceInfo.cbSize = sizeof(RID_DEVICE_INFO);
          nBufferSize = rdiDeviceInfo.cbSize;
  
          // Get Device Info
          nResult = GetRawInputDeviceInfo(pRawInputDeviceList[i].hDevice,
            RIDI_DEVICEINFO,
            &amp;rdiDeviceInfo,
            &amp;nBufferSize);
  
          // Got All Buffer?
          if (nResult &lt; 0)
          {
            // Error
            cout &lt;&lt; "ERR: Unable to read Device Info.. Moving to next device." &lt;&lt; endl &lt;&lt; endl;
  
            // Next
            continue;
          }
  
          // Mouse
          if (rdiDeviceInfo.dwType == RIM_TYPEMOUSE)
          {
            // Current Device
            cout &lt;&lt; endl &lt;&lt; "Displaying device " &lt;&lt; i + 1 &lt;&lt; " information. (MOUSE)" &lt;&lt; endl;
            wcout &lt;&lt; L"Device Name: " &lt;&lt; wcDeviceName &lt;&lt; endl;
            cout &lt;&lt; "Mouse ID: " &lt;&lt; rdiDeviceInfo.mouse.dwId &lt;&lt; endl;
            cout &lt;&lt; "Mouse buttons: " &lt;&lt; rdiDeviceInfo.mouse.dwNumberOfButtons &lt;&lt; endl;
            cout &lt;&lt; "Mouse sample rate (Data Points): " &lt;&lt; rdiDeviceInfo.mouse.dwSampleRate &lt;&lt; endl;
            if (rdiDeviceInfo.mouse.fHasHorizontalWheel)
            {
              cout &lt;&lt; "Mouse has horizontal wheel" &lt;&lt; endl;
            }
            else
            {
              cout &lt;&lt; "Mouse does not have horizontal wheel" &lt;&lt; endl;
            }
          }
  
          // Keyboard
          else if (rdiDeviceInfo.dwType == RIM_TYPEKEYBOARD)
          {
            // Current Device
            cout &lt;&lt; endl &lt;&lt; "Displaying device " &lt;&lt; i + 1 &lt;&lt; " information. (KEYBOARD)" &lt;&lt; endl;
            wcout &lt;&lt; L"Device Name: " &lt;&lt; wcDeviceName &lt;&lt; endl;
            cout &lt;&lt; "Keyboard mode: " &lt;&lt; rdiDeviceInfo.keyboard.dwKeyboardMode &lt;&lt; endl;
            cout &lt;&lt; "Number of function keys: " &lt;&lt; rdiDeviceInfo.keyboard.dwNumberOfFunctionKeys &lt;&lt; endl;
            cout &lt;&lt; "Number of indicators: " &lt;&lt; rdiDeviceInfo.keyboard.dwNumberOfIndicators &lt;&lt; endl;
            cout &lt;&lt; "Number of keys total: " &lt;&lt; rdiDeviceInfo.keyboard.dwNumberOfKeysTotal &lt;&lt; endl;
            cout &lt;&lt; "Type of the keyboard: " &lt;&lt; rdiDeviceInfo.keyboard.dwType &lt;&lt; endl;
            cout &lt;&lt; "Subtype of the keyboard: " &lt;&lt; rdiDeviceInfo.keyboard.dwSubType &lt;&lt; endl;
          }
  
          // Some HID
          else // (rdi.dwType == RIM_TYPEHID)
          {
            // Current Device
            cout &lt;&lt; endl &lt;&lt; "Displaying device " &lt;&lt; i + 1 &lt;&lt; " information. (HID)" &lt;&lt; endl;
            wcout &lt;&lt; L"Device Name: " &lt;&lt; wcDeviceName &lt;&lt; endl;
            cout &lt;&lt; "Vendor Id:" &lt;&lt; rdiDeviceInfo.hid.dwVendorId &lt;&lt; endl;
            cout &lt;&lt; "Product Id:" &lt;&lt; rdiDeviceInfo.hid.dwProductId &lt;&lt; endl;
            cout &lt;&lt; "Version No:" &lt;&lt; rdiDeviceInfo.hid.dwVersionNumber &lt;&lt; endl;
            cout &lt;&lt; "Usage for the device: " &lt;&lt; rdiDeviceInfo.hid.usUsage &lt;&lt; endl;
            cout &lt;&lt; "Usage Page for the device: " &lt;&lt; rdiDeviceInfo.hid.usUsagePage &lt;&lt; endl;
          }
  
          // Delete Name Memory!
          delete[] wcDeviceName;
        }
  
        // Clean Up - Free Memory
        delete[] pRawInputDeviceList;
  
        // Exit
        cout &lt;&lt; endl &lt;&lt; "Finnished.";
        cin.get();
        return 0;
      }
  </code></pre>