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

# XUserFindForDevice

> XUserFindForDevice

# XUserFindForDevice

特定のデバイス ID に対応するユーザー ID を取得します。

## 構文

```cpp theme={null}
HRESULT XUserFindForDevice(  
         const APP_LOCAL_DEVICE_ID* deviceId,  
         XUserHandle* handle  
)  
```

### パラメーター

*deviceId*   \_In\_\
Type: [APP\_LOCAL\_DEVICE\_ID\*](/reference/system/xuser/structs/app_local_device_id)

デバイスの ID です。\
*handle*   \_Out\_\
Type: XUserHandle\*

ローカル ユーザーの XUID が格納されます。

### 戻り値

Type: HRESULT

成功した場合は S\_OK を返します。それ以外の場合はエラー コードを返します。
エラー コードの一覧については、[エラー コード](/reference/errorcodes) を参照してください。

## 解説

<Note>この関数は、時間依存スレッドから呼び出しても安全ではありません。詳細については、[時間依存スレッド](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads) を参照してください。</Note>

ユーザーとデバイスの関連付けは、以下のようなさまざまな理由で変化する場合があります。

* ユーザーが本体からサインアウトする。
* 入力デバイスを使用してアカウント ピッカーで別のユーザーが選択される。

ユーザーとデバイスの関連付けが変化したときに通知を受け取るには、[XUserRegisterForDeviceAssociationChanged](/reference/system/xuser/functions/xuserregisterfordeviceassociationchanged) を呼び出して [XUserDeviceAssociationChangedCallback](/reference/system/xuser/functions/xuserdeviceassociationchangedcallback) を取得します。

<Note>*XUserFindForDevice* は、[XUserAddAsync](/reference/system/xuser/functions/xuseraddasync) の呼び出しでサインインしていないユーザーのユーザー ハンドルを返せません。詳細については、[ユーザーと入力デバイス](/build/core-features/common/user/users-input-devices) を参照してください。</Note>

## 要件

**ヘッダー:** 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)

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

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


## Related topics

- [XUserFindUserById](/ja-jp/reference/system/xuser/functions/xuserfinduserbyid.md)
- [XUserFindUserByLocalId](/ja-jp/reference/system/xuser/functions/xuserfinduserbylocalid.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)
- [ユーザーと入力デバイス](/ja-jp/build/core-features/common/user/users-input-devices.md)
