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

# XUserAddByIdWithUiResult

> XUserAddByIdWithUiResult

Retrieves a handle to the user that [XUserAddByIdWithUiAsync](https://docs.xbox.com/reference/system/xuser/functions/xuseraddbyidwithuiasync.md) 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\*](https://docs.xbox.com/reference/system/xasync/structs/xasyncblock.md)

The [XAsyncBlock](https://docs.xbox.com/reference/system/xasync/structs/xasyncblock.md) previously sent to [XUserAddByIdWithUiAsync](https://docs.xbox.com/reference/system/xuser/functions/xuseraddbyidwithuiasync.md).

*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](https://docs.xbox.com/reference/errorcodes.md).

| Return Code | Description |
| - | - |
| S\_OK | The operation succeeded. |
| E\_GAMEUSER\_USER\_NOT\_FOUND | The user specified in the XUID passed into [XUserAddByIdWithUiAsync](https://docs.xbox.com/reference/system/xuser/functions/xuseraddbyidwithuiasync.md) is no longer signed into the device. |

## Remarks

For more details on how to use this function, see [XUserAddByIdWithUiAsync](https://docs.xbox.com/reference/system/xuser/functions/xuseraddbyidwithuiasync.md).

## Requirements

**Header:** XUser.h

**Library:** xgameruntime.lib

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

## See also

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


## Related topics

- [XUserAddByIdWithUiAsync](https://docs.xbox.com/reference/system/xuser/functions/xuseraddbyidwithuiasync.md)
- [XUser (API contents)](https://docs.xbox.com/reference/system/xuser/xuser_members.md)
- [Using C# wrappers for GDK APIs in your Unity project](https://docs.xbox.com/build/gdk-and-engines/unity/unity-api-wrappers.md)
- [PFGameSaveFilesAddUserWithUiResult](https://docs.xbox.com/services/playfab/api-references/c/pfgamesavefiles/functions/pfgamesavefilesadduserwithuiresult.md)
- [XUserAddResult](https://docs.xbox.com/reference/system/xuser/functions/xuseraddresult.md)
