【问题标题】:HidD_SetOutputReport not resolvedHidD_SetOutputReport 未解决
【发布时间】:2021-02-06 22:30:08
【问题描述】:

我正在尝试与我发现的使用 hid 协议的设备进行交互。我正在使用 signal11 的 hidapi 和 c++,但是我正在使用 hidsdi.h 写入设备,特别是 HidD_SetOutputReport,但是,这会导致“LNK2019:函数 main 中引用的未解析的外部符号 HidD_SetOutputReport”

这是我的代码:

#include <string>
#include <Windows.h>
#include "hidapi.h"
extern "C"
{
    #include <hidsdi.h>
};

using namespace std;

int main()
{
    wchar_t output[255];
    hid_device* portal = NULL;
    
    int result = hid_init();
    portal = hid_open(0x1430, 0x0150, NULL);
    hid_get_product_string(portal, output, 255);
    wprintf(L"product: %s\n", output);
    unsigned char data[0x21];
    memset(data, 0, 0x21);
    data[0] = 0x0;
    data[1] = 0x0B;
    data[2] = 0x14;
    data[3] = 'R';
    if(HidD_SetOutputReport(portal, data, 0x21))
    {
        cout << "write succeeded";
    }
    else
    {
        cout << "write failed";
    }
    hid_exit();
}

如果有人知道这个问题的答案,将不胜感激,在此先感谢!

PS:我在 Windows 上,如果有帮助,我正在使用 Visual Studio 2019

【问题讨论】:

    标签: c++ hid hidapi


    【解决方案1】:

    您必须将您的程序与Hid.lib 链接。

    转到项目设置/链接器并将其添加到所有目标。

    【讨论】:

      猜你喜欢
      • 2016-01-12
      • 2019-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-16
      • 2012-09-06
      • 2011-10-05
      相关资源
      最近更新 更多