XPackageInstallChunksAsync

开始区块的安装。

语法

HRESULT XPackageInstallChunksAsync(  
         const char* packageIdentifier,  
         uint32_t selectorCount,  
         XPackageChunkSelector* selectors,  
         uint32_t minimumUpdateIntervalMs,  
         bool suppressUserConfirmation,  
         XAsyncBlock* asyncBlock  
)  

参数

packageIdentifier _In_z_
类型:char*

唯一标识磁盘上安装的包的字符串。 有关包标识符的详细信息,请参阅管理和许可可下载内容 (DLC)

selectorCount _In_
类型:uint32_t

selectors 参数中的选择器数。

selectors _In_reads_(selectorCount)
类型:XPackageChunkSelector*

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

minimumUpdateIntervalMs _In_
类型:uint32_t

更新之间的时间间隔(以毫秒为单位)。

suppressUserConfirmation _In_
类型:bool

如果要安装的区块超过预设大小,将显示确认提示。 如果 suppressUserConfirmation 为 true,则不会显示提示,并且安装就像用户已接受那样进行。 这让游戏可以提供自己的 UI。 如果游戏使用它,则它应还调用 XPackageEstimateDownloadSize 以便获取将提供给用户的大小。 XPackageEstimateDownloadSize 还会返回一个布尔值,以指示该大小是否足够大,以致要显示提示。 如果需要下载确认,游戏必须使用其自己的 UI 显示它,或者让 XPackageInstallChunks 显示它。

asyncBlock _Inout_
类型:XAsyncBlock*

用于监视异步调用的状态的 XAsyncBlock

返回值

类型:HRESULT

HRESULT 成功或错误代码。

备注

XPackageInstallChunks 具有一个异步变体。 安装区块可能涉及提示用户接受下载大小。

此示例演示如何使用异步 API 安装 BigMaps:

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 主机

另请参阅

XPackage
流式安装和智能交付
XPackageInstallChunks