裝置資訊屬性

每個裝置都有關聯的 DeviceInformation屬性,當你需要特定資訊或建立裝置選擇器時可以使用。 可以使用進階查詢語法(AQS)過濾器來指定這些屬性,並限制列舉中具指定特徵的裝置數量。 你也可以利用這些屬性來指示你希望每個裝置回傳哪些資訊。 這讓你能夠指定回傳給應用程式的裝置資訊。

欲了解更多關於在裝置選擇器中使用 DeviceInformation屬性的資訊,請參見 Build a Device Selector。 本主題說明如何請求屬性資訊,並描述一些常見屬性。

DeviceInformation 物件由一個身份(DeviceInformation.Id)、一種(DeviceInformation.Kind)以及一個屬性袋(DeviceInformation.Properties)組成。 DeviceInformation 物件的所有其他屬性皆源自 Properties 屬性袋。 例如, Name 是從 System.ItemNameDisplay 衍生而來。 這表示財產袋中總是包含判斷其他房產所需的資訊。

請求屬性

DeviceInformation物件有一些基本屬性,例如 IdKind,但大多數屬性都存放在屬性袋中,Properties。 因此,屬性袋包含用來從屬性袋中擷取屬性的各項屬性。 例如,使用 System.ItemNameDisplay 來取得 名稱 屬性。 這是一個常見且眾所周知的屬性,其名稱對使用者相當友善。 Windows 提供數個使用者友善的名稱,方便查詢屬性。

當你申請物件時,你不必侷限於那些名字友善的常見物件。 你可以指定底層的 GUID 和屬性 ID(PID),來請求任何可用的屬性,甚至是由單一裝置或驅動程式提供的自訂屬性。 指定自訂屬性的格式為「{GUID} PID」。 例如:“{744e3bed-3684-4e16-9f8a-07953a8bf2ab} 7”。

Note

你可以在裝置驅動程式的裝置屬性鍵標頭檔中找到屬性 GUID 清單。

有些屬性在所有 DeviceInformationKind 物件中是共通的,但大多數是特定類型的獨有屬性。 以下章節列出一些依個別 DeviceInformationKind 排序的常見屬性。 欲了解更多不同類型之間的關聯,請參閱 DeviceInformationKind

DeviceInterface 屬性

DeviceInterface 是應用程式情境中預設且最常見的 DeviceInformationKind 物件。 除非裝置 API 指定不同的特定 DeviceInformationKind,否則你應該使用這種物件。

Name 類型 Description
System.Devices.ContainerId GUID 包含此 裝置介面裝置 所屬之 DeviceInformationKind.DeviceContainer 的識別。 你可以將這個值連同 DeviceInformationKind.DeviceContainer 一起傳給 CreateFromIdAsync,以找到合適的容器。
System.Devices.InterfaceClassGuid GUID 此介面所代表的介面類別 GUID。
System.Devices.DeviceInstanceId String 父裝置的身份 DeviceInformationKind.Device。 你可以把這個值和 DeviceInformationKind.Device 一起傳給 CreateFromIdAsync,這樣就能找到合適的裝置。
System.Devices.InterfaceEnabled(系統.裝置.介面啟用) 布林值 顯示介面是否啟用。 DeviceInformation.IsEnabled 即源自此屬性。
System.Devices.GlyphIcon String 符文的圖示路徑。
System.Devices.IsDefault 布林值 顯示此裝置是否為 System.Devices.InterfaceClassGuid 的預設裝置。 這主要用於印表機。 這對音訊來說不適用,因為有多種音訊預設。 使用 GetDefaultAudioRenderIDGetDefaultAudioCaptureID 來取得音訊預設值。
System.Devices.Icon String 圖示路徑。
System.ItemNameDisplay String 裝置物件的最佳顯示名稱。

 

裝置屬性

Name 類型 Description
System.Devices.ClassGuid GUID 裝置安裝時使用的裝置類別。 欲了解更多資訊,請參閱 裝置設定類別
System.Devices.CompatibleIds 字串[] 裝置的相容識別碼。 當 Windows 判定要在該裝置上安裝的最佳驅動程式時,會使用這些項目。 欲了解更多資訊,請參閱 相容識別碼
System.Devices.ContainerId GUID 包含此裝置的 DeviceInformationKind.DeviceContainer 的識別碼。 你可以將這個值連同 DeviceInformationKind.DeviceContainer 一起傳給 CreateFromIdAsync,以找到合適的容器。
系統.裝置.裝置功能 UInt32 CfgMgr32.h 中定義的 CM_DEVCAP_X 能力旗標的位元 OR。 欲了解更多資訊,請參閱 DEVPKEY_Device_Capabilities
System.Devices.DeviceHasProblem 布林值 這台裝置目前有問題,很可能無法正常運作。 這可能是因為驅動程式過時、遺失或無效所致。
System.Devices.DeviceInstanceId String 裝置的識別資訊。 這也是 DeviceInformation.Id 的價值所在。
系統.裝置.裝置製造商 String 裝置製造商。
System.Devices.HardwareIds 字串[] 裝置的硬體 ID。 Windows 在決定安裝最佳驅動程式時會使用這些 ID。 裝置供應商可以利用此特性從應用程式中識別裝置。 欲了解更多資訊,請參閱 硬體識別碼
System.Devices.Parent String 父裝置的 DeviceInformation.Id 。 這是連線的父節點,不是 DeviceContainer 的父節點。
System.Devices.Present 布林值 顯示該裝置目前是否存在且可用。
System.ItemNameDisplay String 這個裝置物件的最佳顯示名稱。 在這種情況下,這不一定是最適合使用者的名稱。 較可能的使用者易懂名稱,可藉由參考相關 DeviceContainerDeviceInterfaceSystem.ItemNameDisplay 來取得。

 

DeviceContainer 屬性

Name 類型 Description
系統.裝置.類別 字串[] 這是該裝置所屬類別的描述清單。 此列表以單一類別形式提供。 例如,「顯示器」、「電話」或「音訊裝置」。
System.Devices.CategoryIds 字串[] 包含此裝置所屬類別清單。 例如, Audio.HeadphoneDisplay.MonitorInput.Gaming
系統.裝置.類別複數 字串[] 這是該裝置所屬類別的描述清單。 此列表以複數類別形式提供。 例如,「顯示器」、「電話」或「音訊裝置」。
System.Devices.CompatibleIds 字串[] 所有子 DeviceInformationKind.Device 物件的相容 ID 集合。
系統.裝置.已連線 布林值 顯示該裝置目前是否連接系統。
System.Devices.GlyphIcon String 符文的圖示路徑。
System.Devices.HardwareIds 字串[] 所有子 DeviceInformationKind.Device 物件的硬體 ID 集合。
System.Devices.Icon String 圖示路徑。
System.Devices.LocalMachine 布林值 若此 DeviceContainer 代表系統本身,則為真;若裝置位於系統外部,則為
系統.裝置.製造商 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 即源自此特性。
系統.裝置.AEP類別 字串[] 裝置所屬的類別。 例如,印表機或相機。
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 裝置的型號名稱。
系統.裝置.Aep.協議ID GUID 表示用來發現此 AssocationEndpoint 裝置的協定。
系統.裝置.AEP.訊號強度 Int32 裝置的訊號強度。 此特性僅適用於部分協定。
System.ItemNameDisplay String 裝置最合適的顯示名稱。

 

AssociationEndpointContainer 屬性

Name 類型 Description
System.Devices.AepContainer.Categories 字串[] 裝置所屬的類別。 例如,印表機或相機。
System.Devices.AepContainer.Children 字串[] 這是屬於這個容器的 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 字串[] 這是裝置型號 ID 的清單。 每個模型都是以字串形式呈現的 GUID。
System.Devices.AepContainer.ModelName String 裝置的型號名稱。
System.Devices.AepContainer.ProtocolIds GUID[] 一份對建置此 AssociationEndpointContainer 物件有貢獻的協定 ID 清單。 請記住, AssociationEndpointContainer 裝置是透過收集同一實體裝置在不同協定上發現的所有 AssociationEndpoint 裝置而建立的。
System.Devices.AepContainer.SupportedUriSchemes 字串[] 此裝置支援的投射 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 這是服務中最合適的顯示名稱。