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

# XPackageCloseMountHandle

> XPackageCloseMountHandle

# XPackageCloseMountHandle

关闭指定的装入句柄，并卸载设备。

## 语法

```cpp theme={null}
void XPackageCloseMountHandle(  
         XPackageMountHandle mount  
)  
```

### 参数

*mount*   \_In\_\
类型：XPackageMountHandle

要关闭的装入句柄。

### 返回值

类型：void

## 备注

<Note>此函数在时间敏感线程上调用不安全。有关详细信息，请参阅[时间敏感线程](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)。</Note>

在 [XPackageMount](/reference/system/xpackage/functions/xpackagemount) 装入特定程序包标识符并返回其装入句柄后，XPackageCloseMountHandle 会卸载设备。这可能需要几秒钟。有关程序包标识符的详细信息，请参阅[管理和许可可下载内容 (DLC)](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-manage-and-license-optional-packages)。

[XPackageGetMountPathSize](/reference/system/xpackage/functions/xpackagegetmountpathsize) 和 [XPackageGetMountPath](/reference/system/xpackage/functions/xpackagegetmountpath) 用于返回程序包内容的文件路径。

只能装入内容程序包。尝试装入其他游戏将会得到 E\_ACCESS\_DENIED。

示例：

```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;
}
```

## 要求

**头文件：** XPackage.h

**库：** xgameruntime.lib

**支持的平台：** Windows、XBOX One 系列主机和 XBOX Series 主机

## 概念性文档

* [时间敏感线程](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## 另请参阅

[XPackage](/reference/system/xpackage/xpackage_members)\
[如何为 PC 和 XBOX One 创建和使用可下载内容程序包 (DLC)](/build/core-features/common/packaging/packaging-downloadable-content-dlc)
[XPackageMount](/reference/system/xpackage/functions/xpackagemount)\
[XPackageGetMountPathSize](/reference/system/xpackage/functions/xpackagegetmountpathsize)\
[XPackageGetMountPath](/reference/system/xpackage/functions/xpackagegetmountpath)


## Related topics

- [XPackage](/zh-CN/reference/system/xpackage/xpackage_members.md)
- [面向 GDK 的 Unity C# API 包装器](/zh-CN/build/gdk-and-engines/unity/unity-api-wrappers.md)
- [XPackageCloseInstallationMonitorHandle](/zh-CN/reference/system/xpackage/functions/xpackagecloseinstallationmonitorhandle.md)
- [XPackageMountWithUiResult](/zh-CN/reference/system/xpackage/functions/xpackagemountwithuiresult.md)
- [XPackageGetMountPath](/zh-CN/reference/system/xpackage/functions/xpackagegetmountpath.md)
