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

# XGameStreamingGetTouchBundleVersion

> XGameStreamingGetTouchBundleVersion

# XGameStreamingGetTouchBundleVersion

获取指定设备上当前正在使用的触摸适配包的版本。

## 语法

```cpp theme={null}
HRESULT XGameStreamingGetTouchBundleVersion(  
        XGameStreamingClientId client,
        XVersion* version,
        size_t versionNameSize,
        char* versionName
)  
```

### 参数

*client*   \_In\_\
类型：XGameStreamingClientId

正在查询的流式处理客户端。

*version*   \_Out\_opt\_\
类型：XVersion\*

指定客户端上当前正在使用的包的版本号。如果包中未指定版本号，则将返回 0.0.0.0。

*versionNameSize*   \_In\_\
类型：size\_t

要返回的 `versionName` 的最大大小（以字节为单位）。可通过调用 [XGameStreamingGetTouchBundleVersionNameSize](/reference/system/xgamestreaming/functions/xgamestreaminggettouchbundleversionnamesize) 找到指定的大小。

*versionName*   \_Out\_writes\_opt\_z\_\
类型：char\*

指定客户端上当前正在使用的包的版本名称。如果包中未指定版本名称，则将返回 `null`。

### 返回值

类型：HRESULT

如果成功，则返回 **S\_OK**；否则返回错误代码。

#### 潜在错误

| 错误代码                                     | 错误值        | 错误原因                                                                                                                                       |
| ---------------------------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| E\_GAMESTREAMING\_NOT\_INITIALIZED       | 0x89245400 | XGameStreaming 运行时尚未初始化。在调用其他 API 之前，请先调用 [XGameStreamingInitialize](/reference/system/xgamestreaming/functions/xgamestreaminginitialize)。 |
| E\_GAMESTREAMING\_CLIENT\_NOT\_CONNECTED | 0x89245401 | 指定的客户端未连接。                                                                                                                                 |

有关错误代码列表，请参阅[错误代码](/reference/errorcodes)。

## 备注

在游戏流式处理期间向玩家呈现的触摸布局使用作为触摸适配包的一部分上传到 Microsoft 的预定义布局。`XGameStreamingGetTouchBundleVersion` 使游戏能够根据特定客户端上使用的一组触摸控件做出运行时决策。可能使用此功能的一些示例：

* 如果玩家正在使用触摸且元素可通过触摸叠加控件使用，则从 HUD 中删除该元素。
* 根据将要显示的触摸布局决定在游戏中显示哪些图形提示。

`version` 对上传到服务的每个版本都是唯一的。每次更新都需要一个新的版本号。

`versionName` 可用于提供语义版本（例如，这是一组支持 DLC2 的布局），而不是锁定到特定的版本号。例如，如果版本号由你的构建系统自动分配，则游戏代码可能难以知道运行时将出现的触摸适配包的确切版本号。为了让代码能够检测包的存在而无需知道其确切版本，它可以选择使用版本名称而不是基于版本号进行比较。

## 示例

```C++ theme={null}
void GameStreamingClientManager::GetClientTouchBundleVersion(XGameStreamingClientId client)
{
    // Get the touch bundle version and initialize the touch HUD based on the 
    // semantic version name that was returned
    
    size_t versionNameSize = XGameStreamingGetTouchBundleVersionNameSize(clientId);

    XVersion version{};
    std::vector<char> versionName(versionNameSize, 0);
    XGameStreamingGetTouchBundleVersion(clientId, &version, versionNameSize, &versionName[0]);

    InitializeTouchHUD(versionName);

    if (strcmp("DLC2", versionName.data()) == 0)
    {
        // we have our DLC2 controls, switch to the HUD layout that works best with those overlay controls.
        InitializeHUDForDLC2TouchControls();
    }
}
```

## 要求

**标头：** XGameStreaming.h

**库：** xgameruntime.lib

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

## 另请参阅

[XGameStreaming](/reference/system/xgamestreaming/xgamestreaming_members#ClientProperties)\
[XGameStreamingGetTouchBundleVersionNameSize](/reference/system/xgamestreaming/functions/xgamestreaminggettouchbundleversionnamesize)


## Related topics

- [XGameStreamingGetTouchBundleVersionNameSize](/zh-CN/reference/system/xgamestreaming/functions/xgamestreaminggettouchbundleversionnamesize.md)
- [XGameStreamingClientProperty](/zh-CN/reference/system/xgamestreaming/enums/xgamestreamingclientproperty.md)
- [XGameStreaming](/zh-CN/reference/system/xgamestreaming/xgamestreaming_members.md)
- [Pack 命令](/zh-CN/build/core-features/common/game-streaming/tak-command-line-tool/game-streaming-tak-command-line-pack-command.md)
- [面向 GDK 的 Unity C# API 包装器](/zh-CN/build/gdk-and-engines/unity/unity-api-wrappers.md)
