Partager via


XPackageCloseMountHandle

Closes the specified mount handle, and unmounts the device.

Syntax

void XPackageCloseMountHandle(  
         XPackageMountHandle mount  
)  

Parameters

mount   _In_
Type: XPackageMountHandle

The mount handle to be closed.

Return value

Type: void

Remarks

Note

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

After XPackageMount mounts a particular package identifier and returns a mount handle to it, XPackageCloseMountHandle unmounts the device. This might take several seconds. For more information about package identifiers, see Manage and license downloadable content (DLC).

XPackageGetMountPathSize and XPackageGetMountPath are used to return the file path to the package's contents.

Only content packages can be mounted. An attempt to mount another game will yield E_ACCESS_DENIED.

Example:

HRESULT MountDlc(char* dlcIdentifier)
{
    XPackageMountHandle mountHandle;
    HRESULT hr = XPackageMount(dlcIdentifier, &mountHandle);
    if (FAILED(hr)) return hr;

    size_t pathSize;
    hr = XPackageGetMountPathSize(mountHandle, &pathSize);
    if (FAILED(hr))
    {
        XPackageCloseMountHandle(mountHandle);
        return hr;
    }

    char* path = new (std::nothrow) char[pathSize];
    if (path == nullptr)
    {
        XPackageCloseMountHandle(mountHandle);
        return E_OUTOFMEMORY;
    }

    hr = XPackageGetMountPath(mountHandle, pathSize, path);
    if (FAILED(hr))
    {
        XPackageCloseMountHandle(mountHandle);
        delete[] path;
        return hr;
    }

    printf("Dlc %s mounted at path %s\n", dlcIdentifier, path);

    delete[] path;

    // Unmounts DLC path if this is the last handle
    // to it.
    XPackageCloseMountHandle(mountHandle);
    return S_OK;
}

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 XPackageMount
XPackageGetMountPathSize
XPackageGetMountPath