如何通过WMI获取系统中的所有智能卡读卡器?

Vin*_*ghe 1 .net c# wmi smartcard pcsc

我想使用WMI在我的系统上获取所有PCSC智能卡读卡器的DeviceID和服务.它们都是通过USB连接的,所以我查询所有Win32_PnPEntity的WMI注册表.但我不知道如何确定哪些设备是"读卡器".这是我已经拥有的:

ManagementObjectSearcher mos =
new ManagementObjectSearcher(@"\root\cimv2", @"Select * From Win32_PnPEntity");

ManagementObjectCollection mob = mos.Get();

foreach (ManagementObject mo in mob)
{
    Console.WriteLine("DeviceID: " + mo["DeviceID"].ToString());
    Console.WriteLine("Service: " + mo["Service"].ToString());
}
Run Code Online (Sandbox Code Playgroud)

我不能只是过滤设备名称,有不同的品牌/型号的读者,并没有共同点.在设备管理器中,它们都归为"智能卡读卡器",因此必须采用(其他)方式.

Vin*_*ghe 7

我在MSDN上找到了设备类GUID : {50dd5230-ba8a-11d1-bf5d-0000f805f530}

Smart Card Readers
Class = SmartCardReader
ClassGuid = {50dd5230-ba8a-11d1-bf5d-0000f805f530}
This class includes smart card readers.
Run Code Online (Sandbox Code Playgroud)

最后我想出了这个:

ManagementObjectSearcher mos = new ManagementObjectSearcher(@"\root\cimv2",
@"SELECT* FROM Win32_PnPEntity WHERE ClassGuid = '{50DD5230-BA8A-11D1-BF5D-0000F805F530}'");
Run Code Online (Sandbox Code Playgroud)

这似乎给了我想要的东西:)