c++ - 如何在 C++ 中使用 GUID 查找设备

标签 c++ device guid hid

这是一个由两部分组成的问题。

首先,这是我的代码:

#include<iostream>
#include<Windows.h>

extern "C"
{
#include<hidsdi.h>
#include<SetupAPI.h>
}

int main()
{
    int iQuit;
    GUID guid;

    HidD_GetHidGuid(&guid);
    //SetupDiGetClassDevs(NULL, NULL, NULL, 

    std::cout << "testing program" << std::endl;
    std::cout << guid.Data1 << std::endl;
    std::cout << guid.Data2 << std::endl;
    std::cout << guid.Data3 << std::endl;
    std::cout << guid.Data4 << std::endl;

    std::cin >> iQuit;

    return 0;
}

打印出来的结果是:

1293833650
61807
4559
//Data4 prints out e pie for some reason.

所以我的第一个问题是,有没有办法检查我在此处获得的 guid 属于哪个设备?我查看了设备管理器部分,但似乎找不到它。

我的第二个问题是如何遍历所有设备并将所有 guid 存储在计算机上?

任何建议和帮助将不胜感激。对不起,很长的消息

谢谢

最佳答案

HidD_GetHidGuid 函数返回所有 HID 类设备的 GUID,而不是单个设备的 GUID。

要枚举所有设备,请查看 SetupDiGetClassDevs示例 5.

关于c++ - 如何在 C++ 中使用 GUID 查找设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10500881/

相关文章:

Java final 与 C++ const

android - 针对不同设备应用分辨率

c - 在 CUDA C 中使用简单的设备功能获取 "multiple definition"错误

sql - Nvarchar 和 text 在添加运算符中不兼容

c# - MyGuid.Equals(OtherGuid) 不相等?

c++ - 不同翻译单元中的两个变量违反了单一定义规则?

c++ - 为什么模板只能在头文件中实现?

Powershell 模块 GUID

c++ - 如何在 C++ 中从中获取引用

linux - 在 Linux 中枚举 USB 设备