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

# XGameStreamingGetClients

> XGameStreamingGetClients

# XGameStreamingGetClients

获取每个当前已连接的客户端的 ID。

## 语法

```cpp theme={null}
HRESULT XGameStreamingGetClients(  
         uint32_t clientCount,  
         XGameStreamingClientId* clients,  
         uint32_t* clientsUsed  
)  
```

### 参数

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

在 clients 数组中要返回的客户端最大数量。

*clients*   \_Out\_writes\_to\_(clientCount,*clientsUsed)\
类型：XGameStreamingClientId*

用于存储已连接客户端 ID 的缓冲区。

*clientsUsed*   \_Out\_\
类型：uint32\_t\*

实际写入 clients 数组的客户端数量。

### 返回值

类型：HRESULT

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

#### 潜在错误

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

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

## 备注

用于获取当前已连接的每个流式处理客户端设备的 `XGameStreamingClientId`。

如果游戏仅尝试识别是否有任何设备已连接并进行流式处理，请考虑使用 [XGameStreamingIsStreaming](/reference/system/xgamestreaming/functions/xgamestreamingisstreaming)。

如果游戏需要在流式处理客户端连接和/或断开连接时收到通知，请考虑使用 [XGameStreamingRegisterConnectionStateChanged](/reference/system/xgamestreaming/functions/xgamestreamingregisterconnectionstatechanged)。

## 要求

**标头：** xgamestreaming.h

**库：** xgameruntime.lib

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

## 另请参阅

[XGameStreamingIsStreaming](/reference/system/xgamestreaming/functions/xgamestreamingisstreaming)\
[XGameStreamingRegisterConnectionStateChanged](/reference/system/xgamestreaming/functions/xgamestreamingregisterconnectionstatechanged)\
[XGameStreamingGetClientCount](/reference/system/xgamestreaming/functions/xgamestreaminggetclientcount)\
[XGameStreaming](/reference/system/xgamestreaming/xgamestreaming_members)


## Related topics

- [XGameStreamingGetClientCount](/zh-CN/reference/system/xgamestreaming/functions/xgamestreaminggetclientcount.md)
- [XGameStreamingGetConnectionState](/zh-CN/reference/system/xgamestreaming/functions/xgamestreaminggetconnectionstate.md)
- [XGameStreaming](/zh-CN/reference/system/xgamestreaming/xgamestreaming_members.md)
- [针对 XBOX 游戏串流优化您的游戏](/zh-CN/build/core-features/common/game-streaming/game-streaming-optimizing-your-game.md)
- [面向 GDK 的 Unity C# API 包装器](/zh-CN/build/gdk-and-engines/unity/unity-api-wrappers.md)
