DeviceCapability (Windows 10)

宣告套件所需的裝置功能。 在 Windows 10.0.10240.0 上,最多可以包含 100個 Device 元素。 在 Windows 10.0.10586.0 上,語法和範例最多可以包含 1000 (,請參閱範例) 。

元素階層

<套件>

    <功能>

         <DeviceCapability>

語法

<DeviceCapability
    Name = 'A string with a value between 1 and 50 characters in length or a GUID in the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.' >

  <!-- Child elements -->
  Device{0,1000}

</DeviceCapability>

Key

{} 特定出現的範圍

屬性和元素

屬性

屬性 描述 資料類型 必要 預設值
名稱 裝置功能的名稱,指定為易記名稱或裝置介面類別別 GUID。 長度介於 1 到 50 個字元之間的字串,或格式為 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx 的 GUID。

子元素

子項目 描述
裝置 宣告與 DeviceCapability相關聯之裝置的函式。 在 Windows 10.0.10240.0 上,DeviceCapability最多可以包含 100個 Device元素。 在 Windows 10.0.10586.0 上,最多可以包含 1000 (,如需詳細資訊,請參閱DeviceCapability) 。

父元素

父元素 描述
Capabilities 宣告封裝所需的受保護使用者資源的存取權。 您可以在Capabilities元素中有多個DeviceCapabilityCapability元素,但所有DeviceCapability元素都必須位於Capability元素之後。

備註

如果 Name 屬性指定為 GUID,則會驗證為 GUID。

應用程式預設會授與某些裝置的存取權。 若要存取其他類型的裝置,您必須使用 DeviceCapability 元素來指定它們。 某些裝置功能必須手動新增至套件資訊清單。 如需詳細資訊,請參閱如何在套件資訊清單中指定裝置功能

如需功能宣告的詳細資訊,請參閱 應用程式功能宣告

下列裝置功能需要子項目。

裝置功能 描述
Usb 提供 Windows.Devices.Usb 命名空間中 API 的存取權。 此功能需要子元素。 如需詳細資訊,請參閱 更新 USB 裝置的應用程式資訊清單套件
humaninterfacedevice 提供 Windows.Devices.HumanInterfaceDevice 命名空間中 API 的存取權。 此功能需要子元素。 如需詳細資訊,請參閱如何指定 HID 的裝置功能
bluetooth.genericAttributeProfile 提供 Windows.Devices.Bluetooth.GenericAttributeProfile 命名空間中 API 的存取權。 此功能需要子元素。 如需詳細資訊,請參閱如何指定藍牙的裝置功能
bluetooth.rfcomm 提供 Windows.Devices.Bluetooth.Rfcomm 命名空間中 API 的存取權。 此功能需要子元素。 如需詳細資訊,請參閱如何指定藍牙的裝置功能

範例

以下是可同時在 Windows 10.0.10240.0 和 10.0.10586.0 (運作的功能節點範例,不過,Windows 10.0.10240.0 只會剖析 < device > 元素) 。 另一方面,Windows 10.0.10586.0 支援最多 100 個 <裝置 > 元素加上 < f2:Device > 元素,總計補數為 1000。

<Package
    xmlns:f2="http://schemas.microsoft.com/appx/manifest/foundation/windows10/2">
...
<Dependencies>
    <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.10240.0" MaxVersionTested="10.0.10586.0"/>
</Dependencies>
...
<Capabilities>
    <DeviceCapability Name="microphone"/>
    <DeviceCapability Name="webcam"/>
    <DeviceCapability Name="<name>">
        <Device Id="id_000" ... />
        ...
        <Device Id="id_099" ... />
        <f2:Device Id="id_100" ... />
        ...
        <f2:Device Id="id_999" ... />
    </DeviceCapability>
</Capabilities>

如果您只想要支援 Windows 10.0.10240.0,則只需要 < Device > 元素。 如果您只想要支援 Windows 10.0.10586.0,則只需要 < f2:Device > 元素。

如需更多範例,請參閱 如何在套件資訊清單中指定裝置功能

另請參閱

應用程式功能宣告

如何在封裝資訊清單中指定裝置功能

規格需求

Item
Namespace http://schemas.microsoft.com/appx/manifest/foundation/windows10