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

# 更改游戏的默认用户

> 更改游戏的默认用户

XR-112 要求游戏提供进入账户选择器的入口,以便允许
更改活动(默认)用户。如果游戏正在使用简化用户
模型,并已确保在启动前有必需的默认用户,则
游戏不需要提供此入口。

作为最佳实践,使用简化用户模型的游戏仍可能希望为玩家
提供更改其游戏默认用户的选项。这需要一点点
代码。总的来说,他们需要允许新用户登录,然后使用该用户
重新启动游戏。可以按以下步骤完成:

1. 调用 [XUserAddAsync](/reference/system/xuser/functions/xuseraddasync) 并获取一个 XUserHandle
2. 调用 [XLaunchNewGame](/reference/system/xgame/functions/xlaunchnewgame),指定当前游戏的 EXE
   并使用之前获得的 XUserHandle。

以此方式重新启动游戏后,新用户即是该游戏的默认用户。
如果该用户注销,游戏就会被挂起。
游戏不会为其默认用户收到注销事件。

## 另请参见

[XUserAddAsync](/reference/system/xuser/functions/xuseraddasync)
[XLaunchNewGame](/reference/system/xgame/functions/xlaunchnewgame)


## Related topics

- [用户](/zh-CN/build/core-features/common/user/user-toc.md)
- [GDK 中的用户身份与 XUser API](/zh-CN/build/core-features/common/user/index.md)
- [XUserAddOptions](/zh-CN/reference/system/xuser/enums/xuseraddoptions.md)
- [XUserAddAsync](/zh-CN/reference/system/xuser/functions/xuseraddasync.md)
- [为游戏建立默认用户](/zh-CN/build/core-features/common/user/users-establishing-default-user.md)
