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

# XUserDeviceAssociationChangedCallback

> XUserDeviceAssociationChangedCallback

# XUserDeviceAssociationChangedCallback

用户-设备关联发生更改时调用的回调。

## 语法

```cpp theme={null}
void XUserDeviceAssociationChangedCallback(  
         void* context,  
         const XUserDeviceAssociationChange* change  
)  
```

### 参数

*context*   \_In\_opt\_\
类型：void\*

在回调注册期间，应用程序定义并发送给 [XUserRegisterForDeviceAssociationChanged](https://docs.xbox.com/zh-CN/reference/system/xuser/functions/xuserregisterfordeviceassociationchanged.md) 的上下文。

*change*   \_In\_\
类型：[XUserDeviceAssociationChange\*](https://docs.xbox.com/zh-CN/reference/system/xuser/structs/xuserdeviceassociationchange.md)

包含新旧设备关联的结构。

### 返回值

类型：void

## 注解

若要为用户设备关联更改事件注册回调，请调用 [XUserRegisterForDeviceAssociationChanged](https://docs.xbox.com/zh-CN/reference/system/xuser/functions/xuserregisterfordeviceassociationchanged.md)。该函数接受指向 **XUserDeviceAssociationChangedCallback** 函数的指针作为参数。该函数返回指向回调函数的指针。

## 要求

**头文件：** XUser.h

**库：** xgameruntime.lib

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

## 另请参阅

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

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


## Related topics

- [XUserDeviceAssociationChange](https://docs.xbox.com/zh-CN/reference/system/xuser/structs/xuserdeviceassociationchange.md)
- [XUserFindForDevice](https://docs.xbox.com/zh-CN/reference/system/xuser/functions/xuserfindfordevice.md)
- [XUserRegisterForDeviceAssociationChanged](https://docs.xbox.com/zh-CN/reference/system/xuser/functions/xuserregisterfordeviceassociationchanged.md)
- [用户与手柄的关联在何时发生?](https://docs.xbox.com/zh-CN/build/core-features/common/user/users-timing-of-user-to-device-association.md)
- [XUserFindControllerForUserWithUiAsync](https://docs.xbox.com/zh-CN/reference/system/xuser/functions/xuserfindcontrollerforuserwithuiasync.md)
