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

# XUserFindForDevice

> XUserFindForDevice

Retrieves the user ID for a specific device ID.

## Syntax

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

### Parameters

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

The ID of the device.\
*handle*   \_Out\_\
Type: XUserHandle\*

Contains the XUID for the local user.

### Return value

Type: HRESULT

Returns S\_OK if successful; otherwise, returns an error code.
For a list of error codes, see [Error Codes](https://docs.xbox.com/reference/errorcodes.md).

## Remarks

> [!NOTE]
>
> This function isn't safe to call on a time-sensitive thread. For more information, see [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads).

The association between user and device can change for many reasons:

* The user signs out from the console.
* Someone uses the input device to select a different user in the Account Picker.

To receive a notification when the user-device association changes, call [XUserRegisterForDeviceAssociationChanged](https://docs.xbox.com/reference/system/xuser/functions/xuserregisterfordeviceassociationchanged.md) to get an [XUserDeviceAssociationChangedCallback](https://docs.xbox.com/reference/system/xuser/functions/xuserdeviceassociationchangedcallback.md).

> [!NOTE]
>
> *XUserFindForDevice* cannot return a user handle to a user that hasn't been signed in with a call to [XUserAddAsync](https://docs.xbox.com/reference/system/xuser/functions/xuseraddasync.md). See [Users and input devices](https://docs.xbox.com/build/core-features/common/user/users-input-devices.md) for more information.

## Requirements

**Header:** XUser.h

**Library:** xgameruntime.lib

**Supported platforms:** Windows, XBOX One family consoles and XBOX Series consoles

## Conceptual documentation

* [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## See also

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

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

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


## Related topics

- [XUserFindUserById](https://docs.xbox.com/reference/system/xuser/functions/xuserfinduserbyid.md)
- [XUserFindUserByLocalId](https://docs.xbox.com/reference/system/xuser/functions/xuserfinduserbylocalid.md)
- [APP_LOCAL_DEVICE_ID](https://docs.xbox.com/reference/system/xuser/structs/app_local_device_id.md)
- [Users and input devices](https://docs.xbox.com/build/core-features/common/user/users-input-devices.md)
- [XUser (API contents)](https://docs.xbox.com/reference/system/xuser/xuser_members.md)
