Partager via


XPackageMountWithUiAsync

Asynchronously mounts the installation of specified content, and returns a mount handle to it. Shows user parental consent UI content is age-restricted based on the parental settings of all signed in users.

Syntax

HRESULT XPackageMountWithUiAsync(
  const char * packageIdentifier,
  XAsyncBlock * async
) noexcept;

Parameters

packageIdentifier  _In_z_
Type: const char *

A string that uniquely identifies the installed package on the disk. Pass in the packageIdentifier field from the XPackageDetails struct returned from XPackageEnumerationCallback. For more information about package identifiers, see Manage and license downloadable content (DLC).

async  _Inout_
Type: XAsyncBlock *

An XAsyncBlock for monitoring the status of the asynchronous call.

Return value

Type: HRESULT

HRESULT success or error code.

Remarks

Note that this API will show a parental consent prompt to the user if mounting content that is not age-appropriate for all signed in users. If parental consent is approved, mounting will succeed. If parental consent is denied in the prompt, mounting will fail.

In this scenario a game renders DLC in black and white if the content is age-restricted. External code in the game will call MountDlc when the user selects a piece of DLC to use.

extern void RenderDlc(const char* packageId, const char* displayName, bool monochrome); 

void ShowDlc() 
{ 
// Enumerate all DLC for the game and render it to the user 
XPackageEnumeratePackages(XPackageKind::Content, XPackageEnumerationScope::ThisAndRelated, nullptr,
 [](void*, const XPackageDetails* details) 
  {     
        RenderDlc(details->packageIdentifier,
                  details->displayName, 
                  details->ageRestricted);
  }); 
} 

 HRESULT MountDlc(const char* packageId, XPackageMountHandle* handle)
 {  
    XAsync async{};  
    RETURN_IF_FAILED(XPackageMountWithUiAsync(packageId, &async));
    RETURN_IF_FAILED(XAsyncGetStatus(&async, true));
    RETURN_IF_FAILED(XPackageMountWithUiResult(&async, handle));  
    return S_OK; 
} 

Requirements

Header: XPackage.h

Library: xgameruntime.lib

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

See also

XPackageMountWithUiResult XPackage
XPackageEnumeratePackages
XPackageEnumerationCallback
XPackageDetails
XPackageGetMountPath
XPackageGetMountPathSize
How to create and use Downloadable Content Packages (DLC) for PC and Xbox One