Device Interface Class GUID和Device Setup Class GUID

本文澄清了Device Interface Class GUID和Device Setup Class GUID之间的区别。Device Interface Class GUID对应设备的功能合同,类似COM中的IID,而Device Setup Class GUID用于指定安装INF的安装程序。两者名称相似但概念不同。Windows Runtime设备相关类通常提供GetDeviceSelector()来避免直接使用GUID筛选设备。调用SetupDiGetClassDevs需要注意及时释放返回的设备信息集。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Device Interface Class GUID和Device Setup Class GUID

20180516

两者是不一样的。

There seems to be confusion in this thread about two completely different classes so let me try to clear this up.

A Device Interface Class GUID is the “name” for a functional contract implemented by a device. It is very much the same concept as a IID in COM. A single instance of a device can implement many different functional contracts and therefore have many interfaces with different interface classes.

The Device Setup Class GUID (also referred to as the Installer Class GUID) is a “name” for the installer that should be selected to install a specific INF.

The two concepts are completely unrelated but often confused because they both have “Class GUID” as part of their name.

There is not definitive list of Interface Class GUIDs, and indeed, anyone can define a new one. There are of course some well-known interface classes defined by Windows. I do not know of a list of these either but they tend so to documented with the documentation that describes the functionality of the contract.

In the Windows Runtime device related classes, the class that expose the functionality that you want to use typically has a GetDeviceSelector() function. This selector returns a AQS string that can be used when enumerating devices with Windows.Devices.Enumeration.DeviceInforamtion. This avoids having to know the GUIDs or other details that are needed to filter devices that can be used to activate the functionality that is to be used.

SetupDiGetClassDevs function

注意!!

The caller of SetupDiGetClassDevs must delete the returned device information set when it is no longer needed by calling

bool TpUsbTest::nativeEventFilter(const QByteArray& eventType, void* message, long* result) { Q_UNUSED(eventType); MSG* msg = static_cast<MSG*>(message); if (msg->message == WM_DEVICECHANGE) { PDEV_BROADCAST_HDR broadcastHeader = reinterpret_cast<PDEV_BROADCAST_HDR>(msg->lParam); switch (msg->wParam) { case DBT_DEVICEARRIVAL: if (broadcastHeader && broadcastHeader->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) { PDEV_BROADCAST_DEVICEINTERFACE deviceInterface = reinterpret_cast<PDEV_BROADCAST_DEVICEINTERFACE>(broadcastHeader); QString devicePath = QString::fromWCharArray(deviceInterface->dbcc_name).toUpper(); // 检查是否为目标设备 if (devicePath.contains(QString("%1&%2").arg(TARGET_VID, 4, 16, QChar('0')) .arg(TARGET_PID, 4, 16, QChar('0')))) { UsbDeviceInfo device; device.devicePath = devicePath; device.connected = true; // 提取端口信息 extractPortInfo(device); m_devices[device.devicePath] = device; //emit deviceConnected(devicePath); //emit statusMessage(QString("Device connected: %1 (Port: %2)") // .arg(devicePath).arg(device.port)); //// 如果是测试模式,执行测试 //if (m_isTesting && !m_testedPortsList.contains(device.port)) { // performTest(device.port); //} } } break; case DBT_DEVICEREMOVECOMPLETE: if (broadcastHeader && broadcastHeader->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) { PDEV_BROADCAST_DEVICEINTERFACE deviceInterface = reinterpret_cast<PDEV_BROADCAST_DEVICEINTERFACE>(broadcastHeader); QString devicePath = QString::fromWCharArray(deviceInterface->dbcc_name).toUpper(); if (m_devices.contains(devicePath)) { UsbDeviceInfo device = m_devices[devicePath]; device.connected = false; m_devices[devicePath] = device; //emit deviceDisconnected(devicePath); //emit statusMessage(QString("Device disconnected: %1 (Port: %2)") // .arg(devicePath).arg(device.port)); } } break; } *result = TRUE; return true; } return false; }修改该监听事件,本想监听插拔事件分别进行处理(拔出时记录某设备,插入后判断是否是该设备,并判断插入端口是否发生变化)但是wParam在插拔都是一样的7
最新发布
08-04
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值