Compartilhar via


XPackageEnumerationCallback

The callback used by XPackageEnumeratePackages to enumerate each package.

Syntax

bool XPackageEnumerationCallback(  
         void* context,  
         const XPackageDetails* details  
)  

Parameters

context   _In_
Type: void*

The context passed to XPackageEnumeratePackages when enumeration of the package was initiated.

details   _In_
Type: XPackageDetails*

Pointer to an XPackageDetails structure that contains the installation information for the current package in the enumeration.

Return value

Type: bool

Return true to continue enumerating packages, or false to stop the enumeration.

Remarks

The XPackageEnumerationCallback callback is called for each package during the XPackageEnumeratePackages enumeration.

Both XPackageEnumeratePackages and XPackageRegisterPackageInstalled provide details about an installation, through an XPackageDetails structure. If the package is installing, the installing property of XPackageDetails is true and you can create an installation monitor, to let the package's identifier monitor progress.

There are no generic installation queue notifications; the intent is to use XPackageEnumeratePackages to show and track items in flight, and to use XPackageRegisterPackageInstalled to announce the presence of new DLC. Nor is there a mechanism to start, stop, or cancel an installation. From a game's perspective, the installation should take care of itself. Errors are automatically retried and are invisible to the game.

Example:

bool CALLBACK ListDlcCallback(
    void* /* context */,
    const XPackageDetails* details)
{
    printf("Found dlc: %s\n", details->displayName);
    return true; // continue enumerating
}

HRESULT ListDlc()
{
    HRESULT hr = XPackageEnumeratePackages(
        XPackageKind::Content,                      /* Looking for content packages (DLC) */
        XPackageEnumerationScope::ThisAndRelated,   /* For this game and related games*/
        nullptr, ListDlcCallback);
    return hr;
}

Requirements

Header: XPackage.h

Library: xgameruntime.lib

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

See also

XPackage
How to create and use Downloadable Content Packages (DLC) for PC and Xbox One
XPackageDetails
XPackageEnumeratePackages
XPackageRegisterPackageInstalled