我正在使用的应用程序是使用扫描仪,它可能属于少数类型之一。我需要识别附加的扫描仪,提供从附加扫描仪中选择默认扫描仪的选项,并在需要时更改此选项。到目前为止,我想出了这个解决方案:
ManagementObjectSearcher search = new System.Management.ManagementObjectSearcher("SELECT * From Win32_PnPEntity");
ManagementObjectCollection deviceCollection = search.Get();
foreach (ManagementObject info in deviceCollection)
{
string deviceName = Convert.ToString(info["Caption"]);
if( /* check something about deviceName */)
{
// add a scanner to the list
}
}
这对我有用,因为我知道在信息[“标题”]中会发生什么。 但是,有几个问题: