> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XPackageMountWithUiAsync

> XPackageMountWithUiAsync

# XPackageMountWithUiAsync

以非同步方式掛接指定內容的安裝，並傳回其掛接控制代碼。
如果根據所有已登入使用者的家長監護設定，內容受到年齡限制，則會向使用者顯示家長同意 UI。

## 語法

```cpp theme={null}
HRESULT XPackageMountWithUiAsync(
  const char * packageIdentifier,
  XAsyncBlock * async
) noexcept;
```

### 參數

*packageIdentifier*  \_In\_z\_\
類型：const char \*

可唯一識別磁碟上已安裝套件的字串。
傳入從 [XPackageEnumerationCallback](/zh-TW/reference/system/xpackage/functions/xpackageenumerationcallback) 傳回之 [XPackageDetails](/zh-TW/reference/system/xpackage/structs/xpackagedetails) 結構中的 packageIdentifier 欄位。
如需套件識別碼的詳細資訊，請參閱[管理可下載內容 (DLC) 並授權](/zh-TW/publishing/xstore-commerce/xstore-dlc)。

*async*  \_Inout\_\
類型：XAsyncBlock \*

用來監視非同步呼叫狀態的 **XAsyncBlock**。

### 傳回值

類型：HRESULT

HRESULT 成功或錯誤碼。

## 備註

如果此 API 掛接的內容不適合所有已登入使用者的年齡，此 API 會向使用者顯示家長同意提示。
如果成人使用者在提示中核准家長同意，API 會嘗試掛接套件。
如果成人使用者在提示中拒絕家長同意，API 將無法掛接套件。

此 API 會自動呼叫 [XStoreAcquireLicenseForPackageAsync](/zh-TW/reference/system/xstore/functions/xstoreacquirelicenseforpackageasync) / [Result](/zh-TW/reference/system/xstore/functions/xstoreacquirelicenseforpackageresult) 和 [XStoreIsLicenseValid](/zh-TW/reference/system/xstore/functions/xstoreislicensevalid)。
如果 API 無法取得 DLC 的有效授權，掛接就會失敗。

在此程式碼範例中，如果內容受到年齡限制，遊戲會以黑白方式呈現 DLC。
當使用者選取要使用的 DLC 時，遊戲中的外部程式碼會呼叫 `MountDlc`。

```cpp theme={null}
extern void RenderDlc(const char* packageId, const char* displayName, bool monochrome); 

void ShowDlc() 
{ 
// Enumerate all DLC for the game and render it to the user 
XPackageEnumeratePackages(XPackageKind::Content, XPackageEnumerationScope::ThisAndRelated, nullptr,
 [](void*, const XPackageDetails* details) 
  {     
        RenderDlc(details->packageIdentifier,
                  details->displayName, 
                  details->ageRestricted);
  }); 
} 

 HRESULT MountDlc(const char* packageId, XPackageMountHandle* handle)
 {  
    XAsync async{};  
    RETURN_IF_FAILED(XPackageMountWithUiAsync(packageId, &async));
    RETURN_IF_FAILED(XAsyncGetStatus(&async, true));
    RETURN_IF_FAILED(XPackageMountWithUiResult(&async, handle));  
    return S_OK; 
} 
```

## 需求

**標頭：** XPackage.h

**程式庫：** xgameruntime.lib

**支援的平台：** Windows、XBOX One 系列主機和 XBOX Series 主機

## 概念文件

* [支援遊戲即服務 (GaaS)](/zh-TW/build/core-features/common/packaging/supporting-games-as-a-service)

## 另請參閱

[XPackageMountWithUiResult](/zh-TW/reference/system/xpackage/functions/xpackagemountwithuiresult)
[XPackage](/zh-TW/reference/system/xpackage/xpackage_members)\
[XPackageEnumeratePackages](/zh-TW/reference/system/xpackage/functions/xpackageenumeratepackages)\
[XPackageEnumerationCallback](/zh-TW/reference/system/xpackage/functions/xpackageenumerationcallback)\
[XPackageDetails](/zh-TW/reference/system/xpackage/structs/xpackagedetails)\
[XPackageGetMountPath](/zh-TW/reference/system/xpackage/functions/xpackagegetmountpath)\
[XPackageGetMountPathSize](/zh-TW/reference/system/xpackage/functions/xpackagegetmountpathsize)\
[如何為 PC 和 XBOX One 建立及使用可下載內容套件 (DLC)](/zh-TW/build/core-features/common/packaging/packaging-downloadable-content-dlc)


## Related topics

- [XPackageMountWithUiAsync](/reference/system/xpackage/functions/xpackagemountwithuiasync.md)
- [[DEPRECATED] XPackageMount](/reference/system/xpackage/functions/xpackagemount.md)
- [[EN DESUSO] XPackageMount](/es/reference/system/xpackage/functions/xpackagemount.md)
