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

# XPackage

> XPackage

# XPackage

XPackage API 的参考资料。

## 函数

| 函数                                                                                                                                  | 说明                                                                                                                                     |
| ----------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| [XPackageChangeChunkInstallOrder](/reference/system/xpackage/functions/xpackagechangechunkinstallorder)                             | 将所选区块设为优先安装。                                                                                                                           |
| [XPackageChunkAvailabilityCallback](/reference/system/xpackage/functions/xpackagechunkavailabilitycallback)                         | [XPackageEnumerateChunkAvailability](/reference/system/xpackage/functions/xpackageenumeratechunkavailability) 使用的用户定义回调。               |
| [XPackageCloseInstallationMonitorHandle](/reference/system/xpackage/functions/xpackagecloseinstallationmonitorhandle)               | 关闭指定的安装监视器。                                                                                                                            |
| [XPackageCloseMountHandle](/reference/system/xpackage/functions/xpackageclosemounthandle)                                           | 关闭指定的装载句柄。                                                                                                                             |
| [XPackageCreateInstallationMonitor](/reference/system/xpackage/functions/xpackagecreateinstallationmonitor)                         | 创建安装状态的监视器。                                                                                                                            |
| [XPackageEnumerateChunkAvailability](/reference/system/xpackage/functions/xpackageenumeratechunkavailability)                       | 检查安装包，并枚举所有与指定选择器匹配的区块的可用性。                                                                                                            |
| [XPackageEnumerateFeatures](/reference/system/xpackage/functions/xpackageenumeratefeatures)                                         | 枚举包的布局文件中定义的功能。                                                                                                                        |
| [XPackageEnumeratePackages](/reference/system/xpackage/functions/xpackageenumeratepackages)                                         | 查找与调用进程相关的已安装或正在安装的包。                                                                                                                  |
| [XPackageEnumerationCallback](/reference/system/xpackage/functions/xpackageenumerationcallback)                                     | [XPackageEnumeratePackages](/reference/system/xpackage/functions/xpackageenumeratepackages) 使用的回调。                                     |
| [XPackageEstimateDownloadSize](/reference/system/xpackage/functions/xpackageestimatedownloadsize)                                   | 计算与指定安装选择器匹配的区块的下载大小。                                                                                                                  |
| [XPackageFeatureEnumerationCallback](/reference/system/xpackage/functions/xpackagefeatureenumerationcallback)                       | XPackageEnumerateFeatures 用于枚举每个功能的回调。                                                                                                 |
| [XPackageFindChunkAvailability](/reference/system/xpackage/functions/xpackagefindchunkavailability)                                 | 返回与指定选择器匹配的区块集合的最低可用性。                                                                                                                 |
| [XPackageGetCurrentProcessPackageIdentifier](/reference/system/xpackage/functions/xpackagegetcurrentprocesspackageidentifier)       | 返回一个安装标识字符串，用于标识该进程的安装。                                                                                                                |
| [XPackageGetInstallationProgress](/reference/system/xpackage/functions/xpackagegetinstallationprogress)                             | 返回安装的当前进度。                                                                                                                             |
| [XPackageGetMountPath](/reference/system/xpackage/functions/xpackagegetmountpath)                                                   | 获取已装载安装的路径。                                                                                                                            |
| [XPackageGetMountPathSize](/reference/system/xpackage/functions/xpackagegetmountpathsize)                                           | 获取一个数组所需的大小，用于保存 [XPackageGetMountPath](/reference/system/xpackage/functions/xpackagegetmountpath) 返回的装载路径。                            |
| [XPackageGetUserLocale](/reference/system/xpackage/functions/xpackagegetuserlocale)                                                 | 获取当前用户区域设置。                                                                                                                            |
| [XPackageGetWriteStats](/reference/system/xpackage/functions/xpackagegetwritestats)                                                 | 获取输出写入统计信息 (writeStats)。                                                                                                               |
| [XPackageInstallationProgressCallback](/reference/system/xpackage/functions/xpackageinstallationprogresscallback)                   | [XPackageRegisterInstallationProgressChanged](/reference/system/xpackage/functions/xpackageregisterinstallationprogresschanged) 使用的回调。 |
| [XPackageInstallChunks](/reference/system/xpackage/functions/xpackageinstallchunks)                                                 | 启动区块的安装。                                                                                                                               |
| [XPackageInstallChunksAsync](/reference/system/xpackage/functions/xpackageinstallchunksasync)                                       | 启动区块的安装。                                                                                                                               |
| [XPackageInstallChunksResult](/reference/system/xpackage/functions/xpackageinstallchunksresult)                                     | 检索 [XPackageInstallChunksAsync](/reference/system/xpackage/functions/xpackageinstallchunksasync) 调用的结果。                                |
| [XPackageInstalledCallback](/reference/system/xpackage/functions/xpackageinstalledcallback)                                         | XPackageRegisterPackageInstalled 函数使用的用户定义回调。                                                                                          |
| [XPackageIsPackagedProcess](/reference/system/xpackage/functions/xpackageispackagedprocess)                                         | 返回一个布尔值，指示当前进程是否具有安装标识。                                                                                                                |
| [XPackageMount](/reference/system/xpackage/functions/xpackagemount)                                                                 | 此函数现已弃用。请改用 XPackageMountWithUiAsync。                                                                                                  |
| [XPackageMountWithUiAsync](/reference/system/xpackage/functions/xpackagemountwithuiasync)                                           | 异步装载指定内容的安装，并返回其装载句柄。                                                                                                                  |
| [XPackageMountWithUiResult](/reference/system/xpackage/functions/xpackagemountwithuiresult)                                         | 获取 XPackageMountWithUIAsync 调用的结果。                                                                                                     |
| [XPackageRegisterInstallationProgressChanged](/reference/system/xpackage/functions/xpackageregisterinstallationprogresschanged)     | 注册一个回调，在安装进度发生变化时调用。                                                                                                                   |
| [XPackageRegisterPackageInstalled](/reference/system/xpackage/functions/xpackageregisterpackageinstalled)                           | 注册一个回调，在安装完成时调用。                                                                                                                       |
| [XPackageUninstallPackage](/reference/system/xpackage/functions/xpackageuninstallpackage)                                           | 卸载给定的包。                                                                                                                                |
| [XPackageUninstallChunks](/reference/system/xpackage/functions/xpackageuninstallchunks)                                             | 卸载与指定选择器匹配的区块。                                                                                                                         |
| [XPackageUninstallUWPInstance](/reference/system/xpackage/functions/xpackageuninstalluwpinstance)                                   | 如果当前用户已安装特定包的通用 Windows 平台 (UWP) 实例，则卸载该实例。                                                                                            |
| [XPackageUnregisterInstallationProgressChanged](/reference/system/xpackage/functions/xpackageunregisterinstallationprogresschanged) | 注销先前注册的安装进度变化回调。                                                                                                                       |
| [XPackageUnregisterPackageInstalled](/reference/system/xpackage/functions/xpackageunregisterpackageinstalled)                       | 注销先前注册的安装完成回调。                                                                                                                         |
| [XPackageUpdateInstallationMonitor](/reference/system/xpackage/functions/xpackageupdateinstallationmonitor)                         | 刷新从 [XPackageGetInstallationProgress](/reference/system/xpackage/functions/xpackagegetinstallationprogress) 返回的进度。                     |

## 结构

| 结构                                                                                              | 说明                       |
| ----------------------------------------------------------------------------------------------- | ------------------------ |
| [XPackageChunkSelector](/reference/system/xpackage/structs/xpackagechunkselector)               | 定义用于选择一组区块的条件。           |
| [XPackageDetails](/reference/system/xpackage/structs/xpackagedetails)                           | 包含有关安装的详细信息。             |
| [XPackageFeature](/reference/system/xpackage/structs/xpackagefeature)                           | 描述一项功能。                  |
| [XPackageInstallationProgress](/reference/system/xpackage/structs/xpackageinstallationprogress) | 包含有关安装进度的信息。             |
| [XPackageWriteStats](/reference/system/xpackage/structs/xpackagewritestats)                     | 包含输出写入统计信息 (writeStats)。 |

## 枚举

| 枚举                                                                                      | 说明                |
| --------------------------------------------------------------------------------------- | ----------------- |
| [XPackageChunkAvailability](/reference/system/xpackage/enums/xpackagechunkavailability) | 指示安装区块的可用性。       |
| [XPackageChunkSelectorType](/reference/system/xpackage/enums/xpackagechunkselectortype) | 指示选择器类型。          |
| [XPackageEnumerationScope](/reference/system/xpackage/enums/xpackageenumerationscope)   | 指示枚举安装包时要返回的包的范围。 |
| [XPackageKind](/reference/system/xpackage/enums/xpackagekind)                           | 指示安装包的类型。         |

## 错误代码

以下错误代码可能由 XPackage API 返回。完整列表请参阅[错误代码](/reference/errorcodes)。

| 代码                                       | 值          | 说明                                                             |
| ---------------------------------------- | ---------- | -------------------------------------------------------------- |
| E\_GAMEPACKAGE\_APP\_NOT\_PACKAGED       | 0x89245200 | 游戏未打包在容器中。                                                     |
| E\_GAMEPACKAGE\_NO\_INSTALLED\_LANGUAGES | 0x89245201 | 游戏使用智能交付选择性地安装语言，但未安装任何语言。                                     |
| E\_GAMEPACKAGE\_NO\_STORE\_ID            | 0x89245202 | 必须在应用程序的游戏配置中设置 StoreId 属性。                                    |
| E\_GAMEPACKAGE\_INVALID\_SELECTOR        | 0x89245203 | 提供的区块选择器无法解析为包中的区块。                                            |
| E\_GAMEPACKAGE\_DOWNLOAD\_REQUIRED       | 0x89245204 | 必须下载一个或多个必需区块才能在此设备上装载包。                                       |
| E\_GAMEPACKAGE\_NO\_TAG\_CHANGE          | 0x89245205 | 请使用功能而不是标签更改此包中已安装的区块。                                         |
| E\_GAMEPACKAGE\_DLC\_NOT\_SUPPORTED      | 0x89245206 | 游戏不支持该 DLC 包。请确保游戏配置中的 DLC 兼容性正确。                              |
| E\_GAMEPACKAGE\_DUPLICATE\_ID\_VALUES    | 0x89245207 | 包中包含多个映射到相同 "ID" 属性的可执行文件。请检查 "Executable" 元素中是否存在重复的 "ID" 属性。 |
| E\_GAMEPACKAGE\_NO\_PACKAGE\_IDENTIFIER  | 0x89245208 | 无法解析包的标识符。包可能未安装。                                              |

## 概念文档

* [XStore 检查更新](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-checking-for-updates)
* [XStore 授予对内容的访问权限](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-granting-access-to-content)
* [XStore 管理和授权可选包](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-manage-and-license-optional-packages)

## 另请参阅

[系统 API 参考](/reference/system/gc-reference-system-toc)\
[XStore API 参考](/reference/system/xstore/xstore_members)


## Related topics

- [XPackageUninstallPackage](/zh-CN/reference/system/xpackage/functions/xpackageuninstallpackage.md)
- [XPackageEnumeratePackages](/zh-CN/reference/system/xpackage/functions/xpackageenumeratepackages.md)
- [XPackageRegisterPackageInstalled](/zh-CN/reference/system/xpackage/functions/xpackageregisterpackageinstalled.md)
- [XPackageUnregisterPackageInstalled](/zh-CN/reference/system/xpackage/functions/xpackageunregisterpackageinstalled.md)
- [XPackageDetails](/zh-CN/reference/system/xpackage/structs/xpackagedetails.md)
