0

我正在尝试与我发现使用 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

4

1 回答 1

0

您必须将您的程序与Hid.lib.

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

于 2020-10-23T21:15:57.300 回答