> ## 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](/zh-TW/reference/system/xpackage/functions/xpackagemount) 掛接特定套件識別碼並傳回其掛接控制代碼之後，XPackageCloseMountHandle 會卸載裝置。這可能需要幾秒鐘。如需套件識別碼的詳細資訊，請參閱[管理可下載內容 (DLC) 及授權](/zh-TW/publishing/xstore-commerce/xstore-dlc)。

[XPackageGetMountPathSize](/zh-TW/reference/system/xpackage/functions/xpackagegetmountpathsize) 和 [XPackageGetMountPath](/zh-TW/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](/zh-TW/reference/system/xpackage/xpackage_members)\
[如何為 PC 和 XBOX One 建立及使用可下載內容套件 (DLC)](/zh-TW/build/core-features/common/packaging/packaging-downloadable-content-dlc)
[XPackageMount](/zh-TW/reference/system/xpackage/functions/xpackagemount)\
[XPackageGetMountPathSize](/zh-TW/reference/system/xpackage/functions/xpackagegetmountpathsize)\
[XPackageGetMountPath](/zh-TW/reference/system/xpackage/functions/xpackagegetmountpath)


## Related topics

- [XPackageCloseMountHandle](/reference/system/xpackage/functions/xpackageclosemounthandle.md)
- [XPackage](/reference/system/xpackage/xpackage_members.md)
- [XPersistentLocalStorageMountForPackage](/reference/system/xpersistentlocalstorage/functions/xpersistentlocalstoragemountforpackage.md)
