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

# XUserRegisterForDeviceAssociationChanged

> XUserRegisterForDeviceAssociationChanged

# XUserRegisterForDeviceAssociationChanged

为用户设备关联更改事件注册回调。

## 语法

```cpp theme={null}
HRESULT XUserRegisterForDeviceAssociationChanged(  
         XTaskQueueHandle queue,  
         void* context,  
         XUserDeviceAssociationChangedCallback* callback,  
         XTaskQueueRegistrationToken* token  
)  
```

### 参数

*queue*   \_In\_opt\_\
类型：XTaskQueueHandle

要在其上放置更改回调的异步队列的句柄。

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

应用程序定义并传回给回调的回调。

*callback*   \_In\_\
类型：[XUserDeviceAssociationChangedCallback\*](/reference/system/xuser/functions/xuserdeviceassociationchangedcallback)

应用程序定义并注册的回调。

*token*   \_Out\_\
类型：[XTaskQueueRegistrationToken\*](/reference/system/xtaskqueue/structs/xtaskqueueregistrationtoken)

成功时，包含用于标识回调的令牌，可使用该令牌取消注册回调。

### 返回值

类型：HRESULT

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

## 注解

<Note>在时间敏感线程上调用此函数并不安全。有关详细信息，请参阅[时间敏感线程](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)。</Note>

调用 **XUserDeviceAssociationRegisterForChangeEvent** 不会使先前注册的回调失效。

若要取消注册用户设备关联更改回调，请调用 [XUserUnregisterForDeviceAssociationChanged](/reference/system/xuser/functions/xuserunregisterfordeviceassociationchanged)。

若要注册应用程序定义并在默认终结点更改时调用的回调，请调用 [XUserRegisterForDefaultAudioEndpointUtf16Changed](/reference/system/xuser/functions/xuserregisterfordefaultaudioendpointutf16changed)。

若要取消注册默认音频终结点更改回调，请调用 [XUserUnregisterForDefaultAudioEndpointUtf16Changed](/reference/system/xuser/functions/xuserunregisterfordefaultaudioendpointutf16changed)。

## 要求

**头文件：** XUser.h

**库：** xgameruntime.lib

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

## 概念文档

* [时间敏感线程](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## 另请参阅

[XUser](/reference/system/xuser/xuser_members)

[XUserUnregisterForDeviceAssociationChanged](/reference/system/xuser/functions/xuserunregisterfordeviceassociationchanged)

[XUserRegisterForDefaultAudioEndpointUtf16Changed](/reference/system/xuser/functions/xuserregisterfordefaultaudioendpointutf16changed)

[XUserUnregisterForDefaultAudioEndpointUtf16Changed](/reference/system/xuser/functions/xuserunregisterfordefaultaudioendpointutf16changed)


## Related topics

- [XUserUnregisterForDeviceAssociationChanged](/zh-CN/reference/system/xuser/functions/xuserunregisterfordeviceassociationchanged.md)
- [XUserDeviceAssociationChangedCallback](/zh-CN/reference/system/xuser/functions/xuserdeviceassociationchangedcallback.md)
- [XUserDeviceAssociationChange](/zh-CN/reference/system/xuser/structs/xuserdeviceassociationchange.md)
- [XUserFindForDevice](/zh-CN/reference/system/xuser/functions/xuserfindfordevice.md)
- [XUserRegisterForDefaultAudioEndpointUtf16Changed](/zh-CN/reference/system/xuser/functions/xuserregisterfordefaultaudioendpointutf16changed.md)
