> ## 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)](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-manage-and-license-optional-packages)。

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

*selectors* 参数中的选择器数。

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

指定要安装的区块的选择器数组。

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

更新之间的间隔（以毫秒为单位）。

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

如果要安装的区块超过预设大小，则将显示确认提示。如果 *suppressUserConfirmation* 为 true，则不会显示提示，并且安装将按用户已接受的方式进行。这允许游戏呈现其自己的 UI。如果游戏使用此选项，还应调用 [XPackageEstimateDownloadSize](/reference/system/xpackage/functions/xpackageestimatedownloadsize) 以获取将呈现给用户的大小。[XPackageEstimateDownloadSize](/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 主机

## 概念性文档

* [智能交付：自定义标签说明符](/build/core-features/common/packaging/intelligentdelivery-custom)
* [智能交付：功能和配方](/build/core-features/common/packaging/intelligentdelivery-features-recipes)
* [智能交付：语言说明符](/build/core-features/common/packaging/intelligentdelivery-language)
* [智能交付：按需内容](/build/core-features/common/packaging/intelligentdelivery-ondemand)
* [时间敏感线程](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## 另请参阅

[XPackage](/reference/system/xpackage/xpackage_members)


## Related topics

- [XPackageInstallChunksAsync](/zh-CN/reference/system/xpackage/functions/xpackageinstallchunksasync.md)
- [XPackageInstallChunksResult](/zh-CN/reference/system/xpackage/functions/xpackageinstallchunksresult.md)
- [Intelligent Delivery：自定义标签修饰符](/zh-CN/build/core-features/common/packaging/intelligentdelivery-custom.md)
- [Intelligent Delivery：features 与 recipes](/zh-CN/build/core-features/common/packaging/intelligentdelivery-features-recipes.md)
- [Intelligent Delivery：按需内容](/zh-CN/build/core-features/common/packaging/intelligentdelivery-ondemand.md)
