【问题标题】:Resolving hierarchy of Win32_PnPEntities in WMI解析 WMI 中 Win32_PnPEntities 的层次结构
【发布时间】:2012-01-06 11:23:48
【问题描述】:

我正在使用 WMI 查询来接收插入或拔出 USB 设备时的事件。

SELECT * FROM __InstanceOperationEvent WITHIN 1 WHERE TargetInstance ISA 'Win32_USBControllerDevice'

从收到的事件中,我使用 Dependent 对象来获取 Win32_PnPEntity。

问题是,对于几乎任何物理设备,至少有两个逻辑设备。 所以我收到的数据如下:

Device unplugged: LPK25
Device unplugged: USB Composite Device
Device plugged: LPK25
instance of Win32_PnPEntity
{
        Caption = "LPK25";
        ClassGuid = "{4d36e96c-e325-11ce-bfc1-08002be10318}";
        CompatibleID = {"USB\\Class_01&SubClass_01&Prot_00", "USB\\Class_01&SubClass_01", "USB\\Class_01"};
        ConfigManagerErrorCode = 0;
        ConfigManagerUserConfig = FALSE;
        CreationClassName = "Win32_PnPEntity";
        Description = "USB Audio Device";
        DeviceID = "USB\\VID_09E8&PID_0076&MI_00\\6&383464A1&0&0000";
        HardwareID = {"USB\\VID_09E8&PID_0076&REV_0100&MI_00", "USB\\VID_09E8&PID_0076&MI_00"};
        Manufacturer = "(Generic USB Audio)";
        Name = "LPK25";
        PNPDeviceID = "USB\\VID_09E8&PID_0076&MI_00\\6&383464A1&0&0000";
        Service = "usbaudio";
        Status = "OK";
        SystemCreationClassName = "Win32_ComputerSystem";
        SystemName = "COMPUTER";
};

Device plugged: USB Composite Device
instance of Win32_PnPEntity
{
        Caption = "USB Composite Device";
        ClassGuid = "{36fc9e60-c465-11cf-8056-444553540000}";
        CompatibleID = {"USB\\DevClass_00&SubClass_00&Prot_00", "USB\\DevClass_00&SubClass_00", "USB\\DevClass_00", "USB\\COMPOSITE"};
        ConfigManagerErrorCode = 0;
        ConfigManagerUserConfig = FALSE;
        CreationClassName = "Win32_PnPEntity";
        Description = "USB Composite Device";
        DeviceID = "USB\\VID_09E8&PID_0076\\5&385A3465&0&2";
        HardwareID = {"USB\\VID_09E8&PID_0076&REV_0100", "USB\\VID_09E8&PID_0076"};
        Manufacturer = "(Standard USB Host Controller)";
        Name = "USB Composite Device";
        PNPDeviceID = "USB\\VID_09E8&PID_0076\\5&385A3465&0&2";
        Service = "usbccgp";
        Status = "OK";
        SystemCreationClassName = "Win32_ComputerSystem";
        SystemName = "COMPUTER";
};

显然,其中的LPK25是真实设备,而USB Composite Device是一些伪实体。 对于鼠标,我得到四个实体。对于游戏控制器三等。 那么如何判断其中哪一个是“真品”呢?

【问题讨论】:

    标签: c++ winapi usb wmi


    【解决方案1】:

    据我了解,您正在制造混乱,对我来说,您收到两个事件是正常的。这是因为出现了两个新对象。

    1. 为您提供的低级对象usbccgp 是 USB 音频的低级驱动程序。
    2. 支持您的音频硬件的高级对象。

    我认为您必须按服务进行过滤,例如我使用 USB 密钥进行测试,我有两个事件,一个用于USBSTOR(低级别),另一个用于disk(高级别)。

    【讨论】:

    • 我知道这很正常,但是说我正在解析设备的名称:设备的名称是LPK25,而不是USB Composite Device。如果我在 Windows 中打开设备管理器,它不会显示 USB 复合设备,只有 LPK25 .. 我可以通过 DeviceID/HardwareID 将它们链接在一起,但我希望能够过滤掉过滤器驱动程序和其他Windows 列为单独设备的外壳。
    猜你喜欢
    • 2014-03-18
    • 2014-09-28
    • 2013-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多