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

# XUserFindControllerForUserWithUiAsync

> XUserFindControllerForUserWithUiAsync

# XUserFindControllerForUserWithUiAsync

显示一个对话框，提示用户打开并识别他们想要使用的控制器。

## 语法

```cpp theme={null}
HRESULT XUserFindControllerForUserWithUiAsync(  
         XUserHandle user,  
         XAsyncBlock* async  
)  
```

### 参数

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

要为其查找控制器的用户的 XUserHandle。

*async*   \_In\_\
类型：XAsyncBlock\*

用于轮询调用状态并检索调用结果的 XAsyncBlock。

### 返回值

类型：HRESULT

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

### 注解

在桌面上，此函数不会显示 UI。

若要获取用户选择的控制器的结果，有几种选择。

1. 调用 [XUserFindControllerForUserWithUiResult](/reference/system/xuser/functions/xuserfindcontrollerforuserwithuiresult)。
   这将返回现已绑定控制器的设备 ID。
2. 从 [XUserDeviceAssociationChangedCallback](/reference/system/xuser/functions/xuserdeviceassociationchangedcallback) 回调获取结果，该回调将在用户选择了新控制器后发生。

## 要求

**头文件：** XUser.h

**库：** xgameruntime.lib

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

## 另请参阅

[XUser](/reference/system/xuser/xuser_members)\
[处理控制器丢失（NDA 主题）](/build/core-features/common/user/users-dealing-with-controller-loss)


## Related topics

- [XUserFindControllerForUserWithUiResult](/zh-CN/reference/system/xuser/functions/xuserfindcontrollerforuserwithuiresult.md)
- [处理手柄丢失](/zh-CN/build/core-features/common/user/users-dealing-with-controller-loss.md)
- [用户与手柄的关联在何时发生?](/zh-CN/build/core-features/common/user/users-timing-of-user-to-device-association.md)
- [XR-115 在游戏中添加和移除用户或控制器](/zh-CN/publishing/certification/xr/xr-115.md)
- [XUser](/zh-CN/reference/system/xuser/xuser_members.md)
