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

# XUserFindUserById

> XUserFindUserById

Retrieves the XUserHandle based on the XBOX User ID (XUID) of a local user.

## Syntax

```cpp theme={null}
HRESULT XUserFindUserById(  
         uint64_t userId,  
         XUserHandle* handle  
)  
```

### Parameters

*userId*   \_In\_\
Type: uint64\_t

The local user to retrieve the XUID for.

*handle*   \_Out\_\
Type: XUserHandle\*

Contains the XUID for the local user.

### Return value

Type: HRESULT

HRESULT success or 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).

For each **XUserHandle** handle that you retrieve from an **XUser** API, inluding **XUserFindUserById**, you must
close that handle calling [XUserCloseHandle](https://docs.xbox.com/reference/system/xuser/functions/xuserclosehandle.md).

To retrieve the XBox User ID (XUID) for a local user, call XUserFindUserById.

To retrieve a handle to a user for a specific local user ID, call [XUserFindUserByLocalId](https://docs.xbox.com/reference/system/xuser/functions/xuserfinduserbylocalid.md).

To retrieve a user ID for a specific device ID, call [XUserFindForDevice](https://docs.xbox.com/reference/system/xuser/functions/xuserfindfordevice.md).

## Requirements

**Header:** XUser.h

**Library:** xgameruntime.lib

**Supported platforms:** Windows, Steam Deck, 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)
* [Using the Game Chat 2 C++ API](https://docs.xbox.com/services/xbox-services/multiplayer/chat/game-chat2/using-game-chat-2.md)

## See also

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

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

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


## Related topics

- [XUserFindUserByLocalId](https://docs.xbox.com/reference/system/xuser/functions/xuserfinduserbylocalid.md)
- [XUserGetId](https://docs.xbox.com/reference/system/xuser/functions/xusergetid.md)
- [Using the Game Chat 2 C++ API](https://docs.xbox.com/services/xbox-services/multiplayer/chat/game-chat2/using-game-chat-2.md)
- [XUser (API contents)](https://docs.xbox.com/reference/system/xuser/xuser_members.md)
- [XUserFindForDevice](https://docs.xbox.com/reference/system/xuser/functions/xuserfindfordevice.md)
