无法解析函数 'GetRawInputDeviceList'

Function 'GetRawInputDeviceList' could not be resolved

首次试用此功能使用:

  1. ENV:Eclipse IDE for C/C++ & MinGW32 in Win10-64。
  2. 参考:GetRawInputDeviceList function at Microsoft

我的 hello-world 代码很简单:

#include <iostream>
#include <windows.h>
#include <winuser.h>
using namespace std;

int main() {
     cout << "USB Device Lister." << endl;
     UINT nDevices = 0; 
     PRAWINPUTDEVICELIST pRawInputDeviceList; 

     nHID = GetRawInputDeviceList(NULL, &nDevices, sizeof(RAWINPUTDEVICELIST));
     cout << "found HID devices of "<< nHID << endl;
     return 0;
}

根据 Function definition,我已经包含了 .h,但我仍然遇到错误:

error: 'PRAWINPUTDEVICELIST' was not declared in this scope
Function 'GetRawInputDeviceList' could not be resolved

Some说可能需要#define _WIN32_WINNT 0x0501,或者mingw-x64,但是没有解决我的问题

也尝试定义 WINVER。 所以你应该在 #include <windows.h>

之前添加这个
#define WINVER 0x0501  
#define _WIN32_WINNT 0x0501

查看这篇文章了解更多信息:Modifying WINVER and _WIN32_WINNT

PS。您不必包含 winuser.h,因为它已包含在 windows.h.