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

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

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](/reference/errorcodes).

## 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).</Note>

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](/reference/system/xuser/functions/xuserregisterfordeviceassociationchanged) to get an [XUserDeviceAssociationChangedCallback](/reference/system/xuser/functions/xuserdeviceassociationchangedcallback).

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

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

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

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


## Related topics

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