PointOfService 裝置功能

若要使用 Windows.Devices.PointOfService 命名空間中的 API,需要 PointOfService 裝置功能。

您可以透過在應用程式套件清單中聲明該功能來要求存取 PointOfService API。 大多數功能可以通過 Microsoft Visual Studio 中的清單設計器聲明,也可以手動新增它們。

重要

如果您未在應用程式指令清單中宣告 pointOfService 功能,當您嘗試在 Windows.Devices.PointOfService 命名空間中使用 API 時,將會收到 System.UnauthorizedAccessException 錯誤。

使用清單設計器聲明功能

  1. 方案總管中,展開 UWP 應用程式的項目節點。
  2. 按兩下 Package.appxmanifest 檔案。
    如果指令清單檔案已在 XML 程式碼檢視中開啟,Visual Studio 會提示您關閉檔案。
  3. 按一下 Capabilities 索引標籤。
  4. 按兩下功能清單中的 Point of Service 旁的複選框,以啟用服務點裝置功能

手動宣告功能

  1. 方案總管中,展開 UWP 應用程式的項目節點。
  2. 以滑鼠右鍵按一下 Package.appxmanifest 檔案然後選取檢視程式碼
  3. 將 PointOfService DeviceCapability 元素新增至應用程式指令清單的 Capabilities 區段。
  <Capabilities>
    <DeviceCapability Name="pointOfService" />
  </Capabilities>