问题
I've posted a similar topic/question, but this time it's a bit different.
I'm just trying to use the HidD_GetHidGuid() function to get the window's guid for some hid devices, but it's giving me a error LNK2019: unresolved external symbol _HidD_GetHidGuid@4 referenced in function _main
Heres my code:
//mainframe.cpp
#include<iostream>
#include<Windows.h>
extern "C"
{
#include<hidsdi.h>
#include<SetupAPI.h>
}
int main()
{
int iQuit;
LPGUID guid;
HidD_GetHidGuid(guid);
std::cout << "testing program" << std::endl;
std::cout << guid << std::endl;
std::cin >> iQuit;
return 0;
}
In my VC++ directories I've added C:\WinDDK\7600.16385.1\inc\ddk and C:\WinDDK\7600.16385.1\inc\api to the "include directories". For "Library directories", I have added C:\WinDDK\7600.16385.1\lib
But it's just giving this 1 error, have no idea why... Please help
Thanks
回答1:
According to the documentation, you need to link against hid.lib
回答2:
Add this in your header
pragma comment (lib, "hid.lib")
来源:https://stackoverflow.com/questions/10485643/how-to-use-hidd-gethidguid-in-c