设备信息属性

每个设备都有关联的 DeviceInformation 属性,这些属性可在需要特定信息或生成设备选择器时使用。 高级查询语法 (AQS) 筛选器可用于指定这些属性,并限制具有指定特征的枚举设备。 还可以使用这些属性来指示要为每个设备返回的信息。 这样,便可以指定返回到应用程序的设备信息。

有关在设备选择器中使用 DeviceInformation 属性的详细信息,请参阅生成设备选择器。 本主题演示如何请求信息属性并描述一些常见属性。

DeviceInformation 对象由以下部分构成:标识(DeviceInformation.Id)、类型(DeviceInformation.Kind)和属性包(DeviceInformation.Properties)。 DeviceInformation 对象的其他所有属性都派生自 Properties 属性包。 例如, Name 派生自 System.ItemNameDisplay。 这意味着属性包始终包含确定其他属性所需的信息。

请求属性

DeviceInformation 对象具有一些基本属性, 例如 Id 和 Kind,但大多数属性存储在 properties3 下的属性包中。 因此,属性包包含了用于从该属性包中提取属性的属性。 例如,使用 System.ItemNameDisplay 获取 Name 属性。 这是具有用户友好名称的常见且已知属性的情况。 Windows提供了其中几个用户友好名称,以便更轻松地查询属性。

请求属性时,您并不局限于那些具有用户友好名称的常见属性。 可以指定基础 GUID 和属性 ID(PID),以请求任何可用的属性,甚至请求单个设备或驱动程序提供的自定义属性。 指定自定义属性的格式为“{GUID} PID”。 例如:“{744e3bed-3684-4e16-9f8a-07953a8bf2ab} 7”。

注释

可以在设备驱动程序的设备属性密钥头文件中找到属性 GUID 的列表。

某些属性在所有 DeviceInformationKind 对象中很常见,但大多数属性都特定于特定类型。 以下部分列出了按单个 DeviceInformationKind 排序的一些常见属性。 有关不同类型相互关联的详细信息,请参阅 DeviceInformationKind。

DeviceInterface 属性

DeviceInterface 是应用方案中使用的默认和最常见的 DeviceInformationKind 对象。 这是应使用的对象类型,除非设备 API 指示不同的特定 DeviceInformationKind。

Name 类型 Description
System.Devices.ContainerId GUID 包含此 DeviceInterface 的 Device 所属的 DeviceInformationKind.DeviceContainer 的标识。 可以将此值传递给 CreateFromIdAsync 以及 DeviceInformationKind.DeviceContainer 以查找相应的容器。
System.Devices.InterfaceClassGuid GUID 此接口所表示的接口类 GUID。
System.Devices.DeviceInstanceId String 父级 DeviceInformationKind.Device 的标识。 可以将此值传递给 CreateFromIdAsync 以及 DeviceInformationKind.Device 以查找相应的设备。
System.Devices.InterfaceEnabled 布尔 指示接口是否已启用。 DeviceInformation.IsEnabled 派生自此属性。
System.Devices.GlyphIcon String 标志符号的图标路径。
System.Devices.IsDefault 布尔 指示此设备是否为 System.Devices.InterfaceClassGuid 的默认设备。 这主要用于打印机。 这不适用于音频,因为存在多个音频默认值。 使用 GetDefaultAudioRenderId 或 GetDefaultAudioCaptureId 获取音频默认值。
System.Devices.Icon String 图标路径。
System.ItemNameDisplay String 设备对象的最佳显示名称。

 

设备属性

Name 类型 Description
System.Devices.ClassGuid GUID 设备安装期间使用的设备类。 有关详细信息,请参阅 设备安装类。
System.Devices.CompatibleIds String[] 设备的兼容 ID。 Windows确定设备上安装的最佳驱动程序时,会使用这些驱动程序。 有关详细信息,请参阅 兼容 ID。
System.Devices.ContainerId GUID 包含此设备的 DeviceInformationKind.DeviceContainer 的标识。 可以将此值传递给 CreateFromIdAsync 以及 DeviceInformationKind.DeviceContainer 以查找相应的容器。
System.Devices.DeviceCapabilities UInt32 在 CfgMgr32.h 中定义的CM_DEVCAP_X功能标志的按位 OR。 有关详细信息,请参阅 DEVPKEY_Device_Capabilities。
System.Devices.DeviceHasProblem 布尔 设备当前有问题,可能无法正常工作。 这可能是由于驱动程序已过时、缺失或无效。
System.Devices.DeviceInstanceId String 设备标识。 这也是 DeviceInformation.Id 的值。
System.Devices.DeviceManufacturer String 设备制造商。
System.Devices.HardwareIds String[] 设备的硬件 ID。 Windows确定要安装的最佳驱动程序时使用这些 ID。 设备供应商可以使用此属性从其应用标识其设备。 有关详细信息,请参阅 硬件 ID。
System.Devices.Parent String 父设备的 DeviceInformation.Id。 这是连接父级,而不是 DeviceContainer 父级。
System.Devices.Present 布尔 指示设备当前是否可用。
System.ItemNameDisplay String 此设备对象的最佳显示名称。 在这种情况下,这不一定是用户的最佳名称。 通过引用关联的 DeviceContainer 或 DeviceInterface 的 System.ItemNameDisplay,可以找到用户友好名称的更可能候选项。

 

DeviceContainer 属性

Name 类型 Description
System.Devices.Category String[] 设备所属类别的说明列表。 此列表以单一类别的形式提供。 例如,“显示”、“电话”或“音频设备”。
System.Devices.CategoryIds String[] 包含此设备所属的类别列表。 例如 Audio.Headphone、 Display.Monitor 或 Input.Gaming。
System.Devices.CategoryPlural String[] 设备所属类别的说明列表。 此列表以复数类别的形式提供。 例如,“显示”、“电话”或“音频设备”。
System.Devices.CompatibleIds String[] 所有子 DeviceInformationKind.Device 对象的兼容 ID 集合。
System.Devices.Connected 布尔 指示设备当前是否连接到系统。
System.Devices.GlyphIcon String 标志符号的图标路径。
System.Devices.HardwareIds String[] 所有子 DeviceInformationKind.Device 对象的硬件 ID 集合。
System.Devices.Icon String 图标路径。
System.Devices.LocalMachine 布尔 如果此 DeviceContainer 表示系统本身,则为 True;如果设备在系统外部,则为 false。
System.Devices.Manufacturer String 设备制造商。
System.Devices.ModelName String 设备容器的模型名称。
System.Devices.Paired 布尔 指示任何子 DeviceInformationKind.Device 对象是当前与系统配对的无线设备还是网络设备。
System.ItemNameDisplay String 此设备的最佳显示名称。

 

DeviceInterfaceClass 属性

Name 类型 Description
System.ItemNameDisplay String 此设备的最佳显示名称。

 

DevicePanel 属性

Name 类型 Description
System.Devices.Panel.PanelId String DevicePanel 对象的标识符。
System.Devices.Panel.PanelGroup String 父级 PanelGroup 的标识符。

AssociationEndpoint 属性

Name 类型 Description
System.Devices.Aep.AepId String 此设备的标识。 这也是 DeviceInformation.Id 的值。
System.Devices.Aep.CanPair 布尔 指示设备是否可以与系统配对。 DeviceInformationPairing.CanPair 派生自此属性。
System.Devices.Aep.Category String[] 设备所属的类别。 例如打印机或相机。
System.Devices.Aep.ContainerId GUID 父 AssociationEndpointContainer 对象的 ID。
System.Devices.Aep.DeviceAddress String 设备的地址。 如果设备是网络设备,则这是 IP 地址。
System.Devices.Aep.IsConnected 布尔 指示设备当前是否已连接到系统。
System.Devices.Aep.IsPaired 布尔 指示设备当前是否已配对。 DeviceInformationPairing.IsPaired 派生自此属性。
System.Devices.Aep.IsPresent 布尔 指示设备当前是否存在,这意味着设备是实时的,并通过网络或无线协议发现。 将设备与系统配对后,将缓存设备。 之后,在查询 AssociationEndpoint 对象时,将自动发现设备。 因此,你不能只依赖使用查询来发现设备,以指示它当前是否可用。 这就是为什么此属性很重要的原因。
System.Devices.Aep.Manufacturer String 设备制造商。
System.Devices.Aep.ModelId GUID 设备的型号 ID。
System.Devices.Aep.ModelName String 设备的型号名称。
System.Devices.Aep.ProtocolId GUID 指示用于发现此 AssocationEndpoint 设备的协议。
System.Devices.Aep.SignalStrength Int32 设备的信号强度。 此属性仅适用于某些协议。
System.ItemNameDisplay String 设备最合适的显示名称。

 

AssociationEndpointContainer 属性

Name 类型 Description
System.Devices.AepContainer.Categories String[] 设备所属的类别。 例如打印机或相机。
System.Devices.AepContainer.Children String[] 属于此容器的 AssocationEndpoint 对象的 ID 集合。
System.Devices.AepContainer.CanPair 布尔 指示是否可以将其中一个子 AssociationEndpoint 设备与系统配对。 DeviceInformationPairing.CanPair 派生自此属性。
System.Devices.AepContainer.ContainerId GUID 此设备的标识。 这也是 DeviceInformation.Id 的值,但采用 GUID 形式。
System.Devices.AepContainer.IsPaired 布尔 指示其中一个子 AssociationEndpoint 设备当前是否已配对。 DeviceInformationPairing.IsPaired 派生自此属性。
System.Devices.AepContainer.IsPresent 布尔 指示其中一个子 AssociationEndpoint 设备当前是否存在,即该设备处于在线状态,并且已通过网络或无线协议被发现。 将设备与系统配对后,将缓存设备。 之后,在查询 AssociationEndpoint 对象时,将自动发现设备。 因此,你不能只依赖使用查询来发现设备,以指示它当前是否可用。 这就是为什么此属性很重要的原因。
System.Devices.AepContainer.Manufacturer String 设备制造商。
System.Devices.AepContainer.ModelIds String[] 设备的型号 ID 列表。 每个模型都是字符串形式的 GUID。
System.Devices.AepContainer.ModelName String 设备的型号名称。
System.Devices.AepContainer.ProtocolIds GUID[] 导致生成此 AssociationEndpointContainer 对象的协议 ID 列表。 请记住,AssociationEndpointContainer 设备是通过汇集针对同一物理设备、经由不同协议发现的所有 AssociationEndpoint 设备而创建的。
System.Devices.AepContainer.SupportedUriSchemes String[] 此设备支持的强制转换 URI 方案列表。
System.Devices.AepContainer.SupportsAudio 布尔 指示此设备是否支持音频转换。
System.Devices.AepContainer.SupportsImages 布尔 指示此设备是否支持图像转换。
System.Devices.AepContainer.SupportsVideo 布尔 指示此设备是否支持视频转换。
System.ItemNameDisplay String 设备最合适的显示名称。

 

AssociationEndpointService 属性

Name 类型 Description
System.Devices.AepService.AepId String 父 AssociationEndpoint 对象的标识符。
System.Devices.AepService.ContainerId GUID 父 AssociationEndpointContainer 对象的标识符。
System.Devices.AepService.ParentAepIsPaired 布尔 指示父 AssociationEndpoint 对象是否与系统配对。
System.Devices.AepService.ProtocolId GUID 用于发现此设备的协议的标识。
System.Devices.AepService.ServiceClassId GUID 此设备所代表的服务的标识。
System.Devices.AepService.ServiceId String 此服务的标识。 这也是 DeviceInformation.Id 的值。
System.ItemNameDisplay String 服务的最佳显示名称。