XPackageInstallChunks

Starts the installation of chunks.

Syntax

HRESULT XPackageInstallChunks(  
         const char* packageIdentifier,  
         uint32_t selectorCount,  
         XPackageChunkSelector* selectors,  
         uint32_t minimumUpdateIntervalMs,  
         bool suppressUserConfirmation,  
         XTaskQueueHandle queue,  
         XPackageInstallationMonitorHandle* installationMonitor  
)  

Parameters

packageIdentifier   _In_z_
Type: char*

A string that uniquely identifies the installed package on the disk. For more information about package identifiers, see Manage and license downloadable content (DLC).

selectorCount   _In_
Type: uint32_t

The number of selectors in the selectors parameter.

selectors   _In_reads_(selectorCount)
Type: XPackageChunkSelector*

An array of selectors that specify the chunks to be installed.

minimumUpdateIntervalMs   _In_
Type: uint32_t

The interval between updates, in milliseconds.

suppressUserConfirmation   _In_
Type: bool

If the chunks to be installed exceed a preset size, then a confirmation prompt will be displayed. If suppressUserConfirmation is true, then no prompt will be displayed and the installation will progress as if the user accepted. This lets the game present its own UI. If the game uses this, it should also call XPackageEstimateDownloadSize to get the size that will be presented to the user. XPackageEstimateDownloadSize also returns a Boolean, to indicate whether the size is large enough that a prompt is to be displayed. If a download confirmation is needed, then the game must either show it by using its own UI or let XPackageInstallChunks show it.

queue   _In_opt_
Type: XTaskQueueHandle

The asynchronous queue on which work will be performed.

installationMonitor   _Out_
Type: XPackageInstallationMonitorHandle*

On return, contains a handle to an installation monitor that will monitor the installation of the chunks that match the selector.

Return value

Type: HRESULT

HRESULT success or error code.
Returns a cancellation error if the install is rejected.

Remarks

Note

This function isn't safe to call on a time-sensitive thread. For more information, see Time-sensitive threads.

Installation of chunks might involve prompting the user to accept the download size.

  • If you use the synchronous version of this API, it will block until the user accepts or declines the download. If the user declines, the call will fail with the cancellation error E_ABORT. This will return an installation monitor you can use to monitor the installation status. The monitor must eventually be closed, by calling XPackageCloseInstallationMonitorHandle.
  • Setting suppressUserConfirmation to true will let you provide a custom UI that will prompt the user for the download.

This example will install the chunks that correspond to the "BigMaps" tag:

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;
}

Requirements

Header: XPackage.h

Library: xgameruntime.lib

Supported platforms: Windows, Xbox One family consoles and Xbox Series consoles

See also

XPackage