c++guidhid

How to use HidD_GetHidGuid() in c++?


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 Windows' GUID for some HID devices, but it's giving me the error LNK2019: unresolved external symbol _HidD_GetHidGuid@4 referenced in function _main.

Here's my code:

// mainframe.cpp
#include <Windows.h>
#include <iostream>

extern "C"
{
#include <SetupAPI.h>
#include <hidsdi.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.

However, it's just giving this 1 error, and I have no idea why.


Solution

  • According to the documentation, you need to link against hid.lib