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

# XPackageUninstallChunks

> XPackageUninstallChunks

# XPackageUninstallChunks

卸载与指定选择器匹配的区块。

## 语法

```cpp theme={null}
HRESULT XPackageUninstallChunks(  
         const char* packageIdentifier,  
         uint32_t selectorCount,  
         XPackageChunkSelector* selectors  
)  
```

### 参数

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

用于在磁盘上唯一标识已安装包的字符串。有关包标识符的详细信息，请参阅[管理和授权可下载内容 (DLC)](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-manage-and-license-optional-packages)。

*selectorCount*   \_In\_\
类型：uint32\_t

*selectors* 参数中的选择器数量。

*selectors*   \_In\_reads\_(selectorCount)\
类型：[XPackageChunkSelector\*](/reference/system/xpackage/structs/xpackagechunkselector)

一个选择器数组，用于指定要卸载的区块。

不支持仅使用整数 ID 来指定要卸载的区块；如果尝试这样做，**XPackageUninstallChunks** 将返回 E\_INVALIDARG 值。若要指定要卸载的区块，请为选择器提供其他信息，例如语言或标签。

### 返回值

类型：HRESULT

HRESULT 成功或错误代码。

## 备注

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

**XPackageUninstallChunks** 删除与指定安装选择器匹配的区块。这不会删除包正常运行所必需的区块。例如，你无法删除为当前运行游戏的语言提供资源所必需的区块。

在删除区块时游戏不会停止。游戏需要负责关闭所有指向被删除区块中文件的文件句柄，以及指向不再访问的区块中文件的文件句柄。

在以下示例中，**XPackageUninstallChunks** 用于卸载标签为 "BigMaps" 的地图包：

```cpp theme={null}
HRESULT UninstallBigMaps()
{
    char id[XPACKAGE_IDENTIFIER_MAX_LENGTH];
    HRESULT hr = XPackageGetCurrentProcessPackageIdentifier(_countof(id), id);
    if (FAILED(hr)) return hr;

    XPackageChunkSelector selector;
    selector.type = XPackageChunkSelectorType::Tag;
    selector.tag = "BigMaps";

    hr = XPackageUninstallChunks(id, 1, &selector);
    return hr;
}
```

## 要求

**头文件：** XPackage.h

**库：** xgameruntime.lib

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

## 概念文档

* [智能交付：语言说明符](/build/core-features/common/packaging/intelligentdelivery-language)
* [智能交付：按需内容](/build/core-features/common/packaging/intelligentdelivery-ondemand)
* [时间敏感型线程](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## 另请参阅

[XPackage](/reference/system/xpackage/xpackage_members)\
[流式安装和智能交付](/build/core-features/common/packaging/overviews/streaming_install-intelligent_delivery)


## Related topics

- [XPackageUninstallUWPInstance](/zh-CN/reference/system/xpackage/functions/xpackageuninstalluwpinstance.md)
- [Intelligent Delivery：按需内容](/zh-CN/build/core-features/common/packaging/intelligentdelivery-ondemand.md)
- [XPackage](/zh-CN/reference/system/xpackage/xpackage_members.md)
- [面向 GDK 的 Unity C# API 包装器](/zh-CN/build/gdk-and-engines/unity/unity-api-wrappers.md)
- [XPackageUninstallPackage](/zh-CN/reference/system/xpackage/functions/xpackageuninstallpackage.md)
