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

# XPackageEnumerationCallback

> XPackageEnumerationCallback

# XPackageEnumerationCallback

由 [XPackageEnumeratePackages](/reference/system/xpackage/functions/xpackageenumeratepackages) 用于枚举每个程序包的回调。

## 语法

```cpp theme={null}
bool XPackageEnumerationCallback(  
         void* context,  
         const XPackageDetails* details  
)  
```

### 参数

*context*   \_In\_\
类型：void\*

在启动程序包枚举时传递给 [XPackageEnumeratePackages](/reference/system/xpackage/functions/xpackageenumeratepackages) 的上下文。

*details*   \_In\_\
类型：[XPackageDetails](/reference/system/xpackage/structs/xpackagedetails)\*

指向 [XPackageDetails](/reference/system/xpackage/structs/xpackagedetails) 结构的指针，其中包含枚举中当前程序包的安装信息。

### 返回值

类型：bool

返回 true 以继续枚举程序包，返回 false 以停止枚举。

## 备注

**XPackageEnumerationCallback** 回调在 [XPackageEnumeratePackages](/reference/system/xpackage/functions/xpackageenumeratepackages) 枚举过程中对每个程序包调用。

[XPackageEnumeratePackages](/reference/system/xpackage/functions/xpackageenumeratepackages) 和 [XPackageRegisterPackageInstalled](/reference/system/xpackage/functions/xpackageregisterpackageinstalled) 都通过 [XPackageDetails](/reference/system/xpackage/structs/xpackagedetails) 结构提供有关安装的详细信息。如果程序包正在安装，则 **XPackageDetails** 的 **installing** 属性为 **true**，你可以创建安装监视器，让程序包的标识符监视进度。

没有通用的安装队列通知；其意图是使用 [XPackageEnumeratePackages](/reference/system/xpackage/functions/xpackageenumeratepackages) 来显示和跟踪正在进行的项，并使用 [XPackageRegisterPackageInstalled](/reference/system/xpackage/functions/xpackageregisterpackageinstalled) 宣告新 DLC 的存在。也没有启动、停止或取消安装的机制。从游戏的角度来看，安装应该自动进行。错误会自动重试，对游戏不可见。

示例：

```cpp theme={null}
bool CALLBACK ListDlcCallback(
    void* /* context */,
    const XPackageDetails* details)
{
    printf("Found dlc: %s\n", details->displayName);
    return true; // continue enumerating
}

HRESULT ListDlc()
{
    HRESULT hr = XPackageEnumeratePackages(
        XPackageKind::Content,                      /* Looking for content packages (DLC) */
        XPackageEnumerationScope::ThisAndRelated,   /* For this game and related games*/
        nullptr, ListDlcCallback);
    return hr;
}
```

## 要求

**头文件：** XPackage.h

**库：** xgameruntime.lib

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

## 概念性文档

* [管理和许可可下载内容 (DLC)](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-manage-and-license-optional-packages)

## 另请参阅

[XPackage](/reference/system/xpackage/xpackage_members)\
[如何为 PC 和 XBOX One 创建和使用可下载内容程序包 (DLC)](/build/core-features/common/packaging/packaging-downloadable-content-dlc)\
[XPackageDetails](/reference/system/xpackage/structs/xpackagedetails)\
[XPackageEnumeratePackages](/reference/system/xpackage/functions/xpackageenumeratepackages)\
[XPackageRegisterPackageInstalled](/reference/system/xpackage/functions/xpackageregisterpackageinstalled)


## Related topics

- [XPackageEnumeratePackages](/zh-CN/reference/system/xpackage/functions/xpackageenumeratepackages.md)
- [XPackageMountWithUiAsync](/zh-CN/reference/system/xpackage/functions/xpackagemountwithuiasync.md)
- [管理并授权可下载内容 (DLC)](/zh-CN/publishing/xstore-commerce/xstore-dlc.md)
- [XPackage](/zh-CN/reference/system/xpackage/xpackage_members.md)
- [XPackageFeatureEnumerationCallback](/zh-CN/reference/system/xpackage/functions/xpackagefeatureenumerationcallback.md)
