> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XPackageCloseMountHandle

> XPackageCloseMountHandle

Closes the specified mount handle, and unmounts the device.

## Syntax

```cpp theme={null}
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](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads).

After [XPackageMount](https://docs.xbox.com/reference/system/xpackage/functions/xpackagemount.md) 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)](https://docs.xbox.com/publishing/xstore-commerce/xstore-dlc.md).

[XPackageGetMountPathSize](https://docs.xbox.com/reference/system/xpackage/functions/xpackagegetmountpathsize.md) and [XPackageGetMountPath](https://docs.xbox.com/reference/system/xpackage/functions/xpackagegetmountpath.md) 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:

```cpp theme={null}
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

## Conceptual documentation

* [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## See also

[XPackage](https://docs.xbox.com/reference/system/xpackage/xpackage_members.md)\
[How to create and use Downloadable Content Packages (DLC) for PC and XBOX One](https://docs.xbox.com/build/core-features/common/packaging/packaging-downloadable-content-dlc.md)
[XPackageMount](https://docs.xbox.com/reference/system/xpackage/functions/xpackagemount.md)\
[XPackageGetMountPathSize](https://docs.xbox.com/reference/system/xpackage/functions/xpackagegetmountpathsize.md)\
[XPackageGetMountPath](https://docs.xbox.com/reference/system/xpackage/functions/xpackagegetmountpath.md)


## Related topics

- [XPackage (API contents)](https://docs.xbox.com/reference/system/xpackage/xpackage_members.md)
- [Using C# wrappers for GDK APIs in your Unity project](https://docs.xbox.com/build/gdk-and-engines/unity/unity-api-wrappers.md)
- [XPackageCloseInstallationMonitorHandle](https://docs.xbox.com/reference/system/xpackage/functions/xpackagecloseinstallationmonitorhandle.md)
- [XPackageMount](https://docs.xbox.com/reference/system/xpackage/functions/xpackagemount.md)
- [XPersistentLocalStorageMountForPackage](https://docs.xbox.com/reference/system/xpersistentlocalstorage/functions/xpersistentlocalstoragemountforpackage.md)
