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

# 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](/reference/system/xuser/structs/app_local_device_id)

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

*oldUser*\
Type: [XUserLocalId](/reference/system/xuser/structs/xuserlocalid)

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

*newUser*\
Type: [XUserLocalId](/reference/system/xuser/structs/xuserlocalid)

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

## 解説

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

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

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

これらのメンバーは、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](/reference/system/xuser/functions/xuserdeviceassociationchangedcallback) コールバック関数は、XUserDeviceAssociationChange 構造体へのポインターを使用します。

このコールバック関数は、コールバックの登録時に [XUserRegisterForDeviceAssociationChanged](/reference/system/xuser/functions/xuserregisterfordeviceassociationchanged) 関数へコンテキストを渡します。

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

## 要件

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

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

## 関連項目

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

[XUserDeviceAssociationChangedCallback](/reference/system/xuser/functions/xuserdeviceassociationchangedcallback)

[XUserRegisterForDeviceAssociationChanged](/reference/system/xuser/functions/xuserregisterfordeviceassociationchanged)


## Related topics

- [XUserDeviceAssociationChangedCallback](/ja-jp/reference/system/xuser/functions/xuserdeviceassociationchangedcallback.md)
- [APP_LOCAL_DEVICE_ID](/ja-jp/reference/system/xuser/structs/app_local_device_id.md)
- [XUser](/ja-jp/reference/system/xuser/xuser_members.md)
- [XUserUnregisterForDeviceAssociationChanged](/ja-jp/reference/system/xuser/functions/xuserunregisterfordeviceassociationchanged.md)
- [XUserRegisterForDeviceAssociationChanged](/ja-jp/reference/system/xuser/functions/xuserregisterfordeviceassociationchanged.md)
