我写了这个简单的代码:
static void Main()
{
using (var searcher = new ManagementObjectSearcher("SELECT * FROM win32_PNPEntity WHERE PnPClass='Camera'"))
{
foreach (var device in searcher.Get())
{
Console.WriteLine($"DeviceID => {device["DeviceID"]}");
Console.WriteLine($"PNPDeviceID => {device["PNPDeviceID"]}");
}
}
}
我想获取
Parent
属性,但它似乎不存在。
如果我转到 Device Manager -> Camera -> My Camera -> Property -> Details
我会看到该属性(见图)。怎么才能拿回来?