> ## 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\*](/zh-TW/reference/system/xuser/functions/xuserdeviceassociationchangedcallback)

應用程式定義並註冊的回呼。

*token*   \_Out\_\
類型：[XTaskQueueRegistrationToken\*](/zh-TW/reference/system/xtaskqueue/structs/xtaskqueueregistrationtoken)

成功時，包含識別回呼的權杖，您可以使用此權杖取消註冊回呼。

### 傳回值

類型：HRESULT

HRESULT 成功或錯誤碼。\
如需錯誤碼清單，請參閱[錯誤碼](/zh-TW/reference/errorcodes)。

## 備註

<Note>在時間敏感執行緒上呼叫此函式並不安全。如需詳細資訊，請參閱[時間敏感執行緒](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)。</Note>

呼叫 **XUserDeviceAssociationRegisterForChangeEvent** 不會使先前註冊的回呼失效。

若要取消註冊使用者裝置關聯變更回呼，請呼叫 [XUserUnregisterForDeviceAssociationChanged](/zh-TW/reference/system/xuser/functions/xuserunregisterfordeviceassociationchanged)。

若要註冊由應用程式定義，並在預設端點變更時叫用的回呼，請呼叫 [XUserRegisterForDefaultAudioEndpointUtf16Changed](/zh-TW/reference/system/xuser/functions/xuserregisterfordefaultaudioendpointutf16changed)。

若要取消註冊預設音訊端點變更回呼，請呼叫 [XUserUnregisterForDefaultAudioEndpointUtf16Changed](/zh-TW/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](/zh-TW/reference/system/xuser/xuser_members)

[XUserUnregisterForDeviceAssociationChanged](/zh-TW/reference/system/xuser/functions/xuserunregisterfordeviceassociationchanged)

[XUserRegisterForDefaultAudioEndpointUtf16Changed](/zh-TW/reference/system/xuser/functions/xuserregisterfordefaultaudioendpointutf16changed)

[XUserUnregisterForDefaultAudioEndpointUtf16Changed](/zh-TW/reference/system/xuser/functions/xuserunregisterfordefaultaudioendpointutf16changed)


## Related topics

- [XUserRegisterForDeviceAssociationChanged](/reference/system/xuser/functions/xuserregisterfordeviceassociationchanged.md)
- [XUserDeviceAssociationChangedCallback](/reference/system/xuser/functions/xuserdeviceassociationchangedcallback.md)
- [XUserUnregisterForDeviceAssociationChanged](/reference/system/xuser/functions/xuserunregisterfordeviceassociationchanged.md)
