> ## 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.

# XPackageInstallChunksAsync

> XPackageInstallChunksAsync

# XPackageInstallChunksAsync

開始安裝區塊。

## 語法

```cpp theme={null}
HRESULT XPackageInstallChunksAsync(  
         const char* packageIdentifier,  
         uint32_t selectorCount,  
         XPackageChunkSelector* selectors,  
         uint32_t minimumUpdateIntervalMs,  
         bool suppressUserConfirmation,  
         XAsyncBlock* asyncBlock  
)  
```

### 參數

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

可唯一識別磁碟上已安裝套件的字串。如需套件識別碼的詳細資訊，請參閱[管理可下載內容 (DLC) 並授權](/zh-TW/publishing/xstore-commerce/xstore-dlc)。

*selectorCount*   \_In\_\
類型：uint32\_t

*selectors* 參數中的選取器數目。

*selectors*   \_In\_reads\_(selectorCount)\
類型：[XPackageChunkSelector\*](/zh-TW/reference/system/xpackage/structs/xpackagechunkselector)

指定要安裝之區塊的選取器陣列。

*minimumUpdateIntervalMs*   \_In\_\
類型：uint32\_t

更新之間的間隔，以毫秒為單位。

*suppressUserConfirmation*   \_In\_\
類型：bool

如果要安裝的區塊超過預設大小，將會顯示確認提示。如果 *suppressUserConfirmation* 為 true，則不會顯示提示，且安裝會如同使用者已接受般繼續進行。這可讓遊戲呈現自己的 UI。如果遊戲使用此功能，也應該呼叫 [XPackageEstimateDownloadSize](/zh-TW/reference/system/xpackage/functions/xpackageestimatedownloadsize) 以取得將呈現給使用者的大小。[XPackageEstimateDownloadSize](/zh-TW/reference/system/xpackage/functions/xpackageestimatedownloadsize) 也會傳回布林值，表示大小是否大到需要顯示提示。如果需要下載確認，遊戲必須使用自己的 UI 顯示確認，或讓 **XPackageInstallChunks** 顯示確認。

*asyncBlock*   \_Inout\_\
類型：[XAsyncBlock\*](/zh-TW/reference/system/xasync/structs/xasyncblock)

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

### 傳回值

類型：HRESULT

HRESULT 成功或錯誤碼。

## 備註

[XPackageInstallChunks](/zh-TW/reference/system/xpackage/functions/xpackageinstallchunks) 有非同步變體。安裝區塊時，可能會提示使用者接受下載大小。

此範例示範如何使用非同步 API 安裝 BigMaps：

```cpp theme={null}
void CALLBACK BigMapsInstallProgress(
    void* /* context */,
    XPackageInstallationMonitorHandle monitor)
{
    XPackageInstallationProgress progress;
    XPackageGetInstallationProgress(monitor, &progress);
    if (progress.completed)
    {
        printf("BigMaps Installed\n");
        XPackageCloseInstallationMonitorHandle(monitor);
    }
}

void CALLBACK BigMapsAsyncInstallComplete(XAsyncBlock* asyncBlock)
{
    XPackageInstallationMonitorHandle monitor;
    HRESULT hr = XPackageInstallChunksResult(asyncBlock, &monitor);
    delete asyncBlock;

    if (SUCCEEDED(hr))
    {
        XTaskQueueRegistrationToken token;
        if (FAILED(XPackageRegisterInstallationProgressChanged(
            monitor,
            nullptr,
            BigMapsInstallProgress, &token)))
        {
            XPackageCloseInstallationMonitorHandle(monitor);
        }
    }
}

HRESULT InstallBigMapsAsync(XTaskQueueHandle queue)
{
    char id[XPACKAGE_IDENTIFIER_MAX_LENGTH];
    HRESULT hr = XPackageGetCurrentProcessPackageIdentifier(_countof(id), id);
    if (FAILED(hr)) return hr;

    XPackageChunkSelector selector;
    selector.type = XPackageChunkSelectorType::Tag;
    selector.tag = "BigMaps";

    XAsyncBlock* asyncBlock = new (std::nothrow) XAsyncBlock{};
    asyncBlock->callback = BigMapsAsyncInstallComplete;
    asyncBlock->queue = queue;

    hr = XPackageInstallChunksAsync(
        id, 1, &selector, 1000,
        false, asyncBlock);

    if (FAILED(hr))
    {
        delete asyncBlock;
    }

    return hr;
}
```

## 需求

**標頭：** XPackage.h

**程式庫：** xgameruntime.lib

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

## 概念文件

* [非同步程式設計的設計目標與改進](/zh-TW/build/core-features/common/async/async-whitepaper)

## 另請參閱

[XPackage](/zh-TW/reference/system/xpackage/xpackage_members)\
[串流安裝和 Intelligent Delivery](/zh-TW/build/core-features/common/packaging/overviews/streaming_install-intelligent_delivery)\
[XPackageInstallChunks](/zh-TW/reference/system/xpackage/functions/xpackageinstallchunks)


## Related topics

- [XPackageInstallChunksAsync](/reference/system/xpackage/functions/xpackageinstallchunksasync.md)
- [XPackageInstallChunksResult](/reference/system/xpackage/functions/xpackageinstallchunksresult.md)
- [XPackage](/reference/system/xpackage/xpackage_members.md)
- [Asynchronous programming design goals and improvements](/build/core-features/common/async/async-whitepaper.md)
- [XPackageInstallChunks](/reference/system/xpackage/functions/xpackageinstallchunks.md)
