问题描述
我正在尝试与我发现使用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,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
解决方法
您必须将程序与Hid.lib
关联。
转到项目设置/链接器,并将其添加到所有目标。