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

# XPackageInstallChunks

> XPackageInstallChunks

# XPackageInstallChunks

開始安裝區塊。

## 語法

```cpp theme={null}
HRESULT XPackageInstallChunks(  
         const char* packageIdentifier,  
         uint32_t selectorCount,  
         XPackageChunkSelector* selectors,  
         uint32_t minimumUpdateIntervalMs,  
         bool suppressUserConfirmation,  
         XTaskQueueHandle queue,  
         XPackageInstallationMonitorHandle* installationMonitor  
)  
```

### 參數

*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** 顯示確認。

*queue*   \_In\_opt\_\
類型：XTaskQueueHandle

將在其上執行工作的非同步佇列。

*installationMonitor*   \_Out\_\
類型：XPackageInstallationMonitorHandle\*

傳回時，包含安裝監視器的控制代碼，該監視器將監視符合選取器之區塊的安裝。

### 傳回值

類型：HRESULT

HRESULT 成功或錯誤碼。\
如果安裝遭到拒絕，則會傳回取消錯誤。

## 備註

<Note>在時間敏感的執行緒上呼叫此函式並不安全。如需詳細資訊，請參閱[時間敏感的執行緒](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)。</Note>

安裝區塊時，可能會提示使用者接受下載大小。

* 如果您使用此 API 的同步版本，它會封鎖直到使用者接受或拒絕下載為止。如果使用者拒絕，呼叫將會失敗並傳回取消錯誤 E\_ABORT。這會傳回可用來監視安裝狀態的安裝監視器。最終必須呼叫 XPackageCloseInstallationMonitorHandle 來關閉監視器。
* 將 suppressUserConfirmation 設定為 true，可讓您提供自訂 UI 來提示使用者下載。

此範例會安裝對應至 "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);
    }
}

HRESULT InstallBigMaps(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";

    XPackageInstallationMonitorHandle monitor;
    hr = XPackageInstallChunks(id, 1, &selector, 1000, false, queue, &monitor);

    if (SUCCEEDED(hr))
    {
        XTaskQueueRegistrationToken token;
        hr = XPackageRegisterInstallationProgressChanged(
            monitor,
            nullptr,
            BigMapsInstallProgress,
            &token);

        if (FAILED(hr))
        {
            XPackageCloseInstallationMonitorHandle(monitor);
        }
    }

    return hr;
}
```

## 需求

**標頭：** XPackage.h

**程式庫：** xgameruntime.lib

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

## 概念文件

* [Intelligent Delivery：自訂標記指定元](/zh-TW/build/core-features/common/packaging/intelligentdelivery-custom)
* [Intelligent Delivery：功能和配方](/zh-TW/build/core-features/common/packaging/intelligentdelivery-features-recipes)
* [Intelligent Delivery：語言指定元](/zh-TW/build/core-features/common/packaging/intelligentdelivery-language)
* [Intelligent Delivery：OnDemand 內容](/zh-TW/build/core-features/common/packaging/intelligentdelivery-ondemand)
* [時間敏感的執行緒](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## 另請參閱

[XPackage](/zh-TW/reference/system/xpackage/xpackage_members)


## Related topics

- [XPackageInstallChunks](/ja-jp/reference/system/xpackage/functions/xpackageinstallchunks.md)
- [XPackageInstallChunksAsync](/reference/system/xpackage/functions/xpackageinstallchunksasync.md)
- [XPackageInstallChunksResult](/reference/system/xpackage/functions/xpackageinstallchunksresult.md)
- [Intelligent Delivery: custom tag specifiers](/build/core-features/common/packaging/intelligentdelivery-custom.md)
- [Intelligent Delivery: features and recipes](/build/core-features/common/packaging/intelligentdelivery-features-recipes.md)
