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

# XUserDeviceAssociationChange

> XUserDeviceAssociationChange

# XUserDeviceAssociationChange

デバイスとの関連付けが変更されたときの、以前のデバイス関連付けおよび新しいデバイス関連付けを指定します。

## 構文

```cpp theme={null}
typedef struct XUserDeviceAssociationChange {  
    APP_LOCAL_DEVICE_ID deviceId;  
    XUserLocalId oldUser;  
    XUserLocalId newUser;  
} XUserDeviceAssociationChange  
```

### メンバー

*deviceId*\
Type: [APP\_LOCAL\_DEVICE\_ID](https://docs.xbox.com/ja-jp/reference/system/xuser/structs/app_local_device_id.md)

ユーザーの関連付けが変更されたデバイスの ID です。

*oldUser*\
Type: [XUserLocalId](https://docs.xbox.com/ja-jp/reference/system/xuser/structs/xuserlocalid.md)

デバイスに関連付けられていた以前のユーザー ID です。

*newUser*\
Type: [XUserLocalId](https://docs.xbox.com/ja-jp/reference/system/xuser/structs/xuserlocalid.md)

デバイスに新しく関連付けられたユーザー ID です。

## 解説

XUserDeviceAssociationChange のすべての引数は「null」になる可能性があります。

* deviceId が **XUserNullDeviceId** に等しい場合、ユーザーの変更はすべてのデバイスに適用されます。この場合、すべてのデバイスがサインイン済みのユーザーと関連付けられています。
* oldUser が **XUserNullUserLocalId** に等しい場合、そのデバイスとユーザーの関連付けは新規のものです。
* newUser が **XUserNullUserLocalId** に等しい場合、既存のデバイスとユーザーの関連付けは失われています。

> [!NOTE]
>
> *newUser* は、[XUserAddAsync](https://docs.xbox.com/ja-jp/reference/system/xuser/functions/xuseraddasync.md) の呼び出しによって既にタイトルに追加済みのユーザーのみを参照できます。システム ピッカーが、タイトルが認識していないユーザーに入力デバイスをペアリングするために使用された場合、newUser は **XUserNullUserLocalId** に等しくなります。詳しくは、「[ユーザーと入力デバイス](https://docs.xbox.com/ja-jp/build/core-features/common/user/users-input-devices.md)」をご覧ください。

これらのメンバーは、memcmp または同等の方法で比較できる生のバイト構造として扱う必要があります。次に例を示します。

```cpp theme={null}
XUserDeviceAssociationChange *change; // incoming argument from callback

if(memcmp(&change->deviceId, &XUserNullDeviceId, sizeof(APP_LOCAL_DEVICE_ID) == 0))
{
}

if(memcmp(&change->newUser, &XUserNullUserLocalId, sizeof(XUserLocalId) == 0))
{
}
```

[XUserDeviceAssociationChangedCallback](https://docs.xbox.com/ja-jp/reference/system/xuser/functions/xuserdeviceassociationchangedcallback.md) コールバック関数は、XUserDeviceAssociationChange 構造体へのポインターを使用します。

このコールバック関数は、コールバックの登録時に [XUserRegisterForDeviceAssociationChanged](https://docs.xbox.com/ja-jp/reference/system/xuser/functions/xuserregisterfordeviceassociationchanged.md) 関数へコンテキストを渡します。

[XUserRegisterForDeviceAssociationChanged](https://docs.xbox.com/ja-jp/reference/system/xuser/functions/xuserregisterfordeviceassociationchanged.md) 関数は、ユーザーとデバイスの関連付け変更イベント用のコールバックを登録します。

## 要件

**ヘッダー:** XUser.h

**サポートされているプラットフォーム:** Windows、XBOX One ファミリ本体および XBOX Series 本体

## 関連項目

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

[XUserDeviceAssociationChangedCallback](https://docs.xbox.com/ja-jp/reference/system/xuser/functions/xuserdeviceassociationchangedcallback.md)

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


## Related topics

- [XUserDeviceAssociationChangedCallback](https://docs.xbox.com/ja-jp/reference/system/xuser/functions/xuserdeviceassociationchangedcallback.md)
- [APP_LOCAL_DEVICE_ID](https://docs.xbox.com/ja-jp/reference/system/xuser/structs/app_local_device_id.md)
- [XUser (API の内容)](https://docs.xbox.com/ja-jp/reference/system/xuser/xuser_members.md)
- [XUserRegisterForDeviceAssociationChanged](https://docs.xbox.com/ja-jp/reference/system/xuser/functions/xuserregisterfordeviceassociationchanged.md)
- [XUserUnregisterForDeviceAssociationChanged](https://docs.xbox.com/ja-jp/reference/system/xuser/functions/xuserunregisterfordeviceassociationchanged.md)
