> ## 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.

# XPackageUninstallPackage

> XPackageUninstallPackage

# XPackageUninstallPackage

解除安裝指定的套件。

## 語法

```cpp theme={null}

bool XPackageUninstallPackage(
    const char* packageIdentifier) 
noexcept;
```

### 參數

*packageIdentifier*   \_In\_z\_\
類型：char\*

可唯一識別磁碟上已安裝套件的字串。如需套件識別碼的詳細資訊，請參閱[管理可下載內容 (DLC) 並授權](/zh-TW/publishing/xstore-commerce/xstore-dlc)。

### 傳回值

類型：bool

布林值，表示套件是否已成功解除安裝。

## 備註

<Note>在時間敏感的執行緒上呼叫此函式並不安全。如需詳細資訊，請參閱[時間敏感的執行緒](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)。</Note>

**XPackageUninstallPackage** 會解除安裝指定的套件。所提供的套件識別碼應是從 **XPackageEnumeratePackages** 或其他會傳回套件識別碼的 API 所傳回。如果套件已解除安裝，**XPackageUninstallPackage** 會傳回 true；如果無法解除安裝套件，則傳回 false。

套件解除安裝失敗的原因包括：

* 套件正在使用中。例如，它是遊戲目前已掛接的 DLC 套件。
* 遊戲正在 xCloud 伺服器上執行。套件的安裝和移除由伺服器環境負責。

在下列範例中，**XPackageUninstallPackage** 用來解除安裝套件，以便為使用者釋放磁碟空間。

```cpp theme={null}
bool UninstallDlcToReclaimDiskSpace(const char_t* packageIdentifier) 
{
return XPackageUninstallPackage(packageIdentifier);
} 
```

## 需求

**標頭：** XPackage.h

**程式庫：** xgameruntime.lib

**支援的平台：** Windows、XBOX One 系列主機和 XBOX Series 主機

## 概念文件

* [管理可下載內容 (DLC) 並授權](/zh-TW/publishing/xstore-commerce/xstore-dlc)

## 另請參閱

[XPackage](/zh-TW/reference/system/xpackage/xpackage_members)\
[串流安裝和 Intelligent Delivery](/zh-TW/build/core-features/common/packaging/overviews/streaming_install-intelligent_delivery)


## Related topics

- [XPackageUninstallPackage](/reference/system/xpackage/functions/xpackageuninstallpackage.md)
- [Manage and license downloadable content (DLC)](/publishing/xstore-commerce/xstore-dlc.md)
- [XPackage](/reference/system/xpackage/xpackage_members.md)
- [管理并授权可下载内容 (DLC)](/zh-CN/publishing/xstore-commerce/xstore-dlc.md)
- [Administración y licencias de contenido descargable (DLC)](/es/publishing/xstore-commerce/xstore-dlc.md)
