How to use HidD_GetHidGuid() in c++?

一曲冷凌霜 提交于 2019-12-02 06:40:33

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!