> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XUserGetId

> XUserGetId

# XUserGetId

获取特定用户的用户 ID。

## 语法

```cpp theme={null}
HRESULT XUserGetId(  
         XUserHandle user,  
         uint64_t* userId  
)  
```

### 参数

*user*   \_In\_\
类型：XUserHandle

要检索用户 ID 的用户的句柄。

*userId*   \_Out\_\
类型：uint64\_t\*

包含特定用户的用户 ID。

### 返回值

类型：HRESULT

HRESULT 成功或错误代码。

| 返回代码 | 说明 |
| - | - |
| S\_OK | 操作成功。 |
| E\_GAMEUSER\_RESOLVE\_USER\_ISSUE\_REQUIRED | 用户必须使用 UI 来解决该问题。调用 [XUserResolveIssueWithUiAsync](https://docs.xbox.com/zh-CN/reference/system/xuser/functions/xuserresolveissuewithuiasync.md) 以向用户显示 UI。 |

## 注解

检索用户的 XUID。如果函数返回 **E\_GAMEUSER\_RESOLVE\_USER\_ISSUE\_REQUIRED**，用户需要使用系统 UI 解决问题，之后函数才能检索该属性。调用 [XUserResolveIssueWithUiAsync](https://docs.xbox.com/zh-CN/reference/system/xuser/functions/xuserresolveissuewithuiasync.md) 以显示系统 UI 并解决该问题。

## 要求

**头文件：** XUser.h

**库：** xgameruntime.lib

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

## 概念文档

* [使用 Game Chat 2 C++ API](https://docs.xbox.com/zh-CN/services/xbox-services/multiplayer/chat/game-chat2/using-game-chat-2.md)

## 另请参阅

[XUser](https://docs.xbox.com/zh-CN/reference/system/xuser/xuser_members.md)

[XUserFindUserById](https://docs.xbox.com/zh-CN/reference/system/xuser/functions/xuserfinduserbyid.md)

[XUserFindUserByLocalId](https://docs.xbox.com/zh-CN/reference/system/xuser/functions/xuserfinduserbylocalid.md)


## Related topics

- [XUserGetLocalId](https://docs.xbox.com/zh-CN/reference/system/xuser/functions/xusergetlocalid.md)
- [XUserGetMaxUsers](https://docs.xbox.com/zh-CN/reference/system/xuser/functions/xusergetmaxusers.md)
- [XUserGetGamertag](https://docs.xbox.com/zh-CN/reference/system/xuser/functions/xusergetgamertag.md)
- [用户身份与 XUser](https://docs.xbox.com/zh-CN/build/core-features/common/user/player-identity-xuser.md)
- [PC 上的 XStore — DRM、许可证令牌和沙盒](https://docs.xbox.com/zh-CN/publishing/xstore-commerce/xstore-pc.md)
