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

# XUserAddByIdWithUiResult

> XUserAddByIdWithUiResult

# XUserAddByIdWithUiResult

Retrieves a handle to the user that [XUserAddByIdWithUiAysnc](/reference/system/xuser/functions/xuseraddbyidwithuiasync) creates.
This function should only be used in response to a game invite.

## Syntax

```cpp theme={null}
HRESULT XUserAddByIdWithUiResult(  
         XAsyncBlock* async,  
         XUserHandle* newUser  
)  
```

### Parameters

*async*   \_Inout\_\
Type: [XAsyncBlock\*](/reference/system/xasync/structs/xasyncblock)

The [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) previously sent to [XUserAddByIdWithUiAysnc](/reference/system/xuser/functions/xuseraddbyidwithuiasync).

*newUser*   \_Out\_\
Type: XUserHandle\*

Contains a handle to the new user.

### Return value

Type: HRESULT

HRESULT success or error code.
For a list of error codes, see [Error Codes](/reference/errorcodes).

| Return Code                 | Description                                                                                                                                                          |
| --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| S\_OK                       | The operation succeeded.                                                                                                                                             |
| E\_GAMEUSER\_USER\_NOTFOUND | The user specified in the XUID passed into [XUserAddByIdWithUiAysnc](/reference/system/xuser/functions/xuseraddbyidwithuiasync) is no longer signed into the device. |

## Remarks

For more details on how to use this function, see [XUserAddByIdWithUiAysnc](/reference/system/xuser/functions/xuseraddbyidwithuiasync).

## Requirements

**Header:** XUser.h

**Library:** xgameruntime.lib

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

## See also

[XUser](/reference/system/xuser/xuser_members)\
[XUserCloseHandle](/reference/system/xuser/functions/xuserclosehandle)


## Related topics

- [XUserAddByIdWithUiAsync](/reference/system/xuser/functions/xuseraddbyidwithuiasync.md)
- [XUser](/reference/system/xuser/xuser_members.md)
- [Unity C# API wrappers for the GDK](/build/gdk-and-engines/unity/unity-api-wrappers.md)
- [XUserAddResult](/reference/system/xuser/functions/xuseraddresult.md)
- [XUserFindControllerForUserWithUiResult](/reference/system/xuser/functions/xuserfindcontrollerforuserwithuiresult.md)
