XUserAddResult
Retrieves a handle to a user that XUserAddAsync creates.Syntax
Parameters
async _Inout_Type: XAsyncBlock* The async block sent to XUserAddAsync. newUser _Out_
Type: XUserHandle* Contains a handle to the new user.
Return value
Type: HRESULT HRESULT success or error code.Remarks
XUserAddAsync starts an asynchronous operation to add a user to the game. Use XUserAddResult to retrieve the results of the operation. XUserAddAsync always shows an account picker UI unless you pass XUserAddOptions::AddDefaultUserSilently to the options parameter. If you use XUserAddOptions::AddDefaultUserSilently, XUserAddAsync does not show a UI. The user that XUserAddOptions::AddDefaultUserSilently returns continues to return until the user signs out. If a default user is not available, XUserAddResult returns E_GAMEUSER_NO_DEFAULT_USER. This indicates that you must call XUserAddAsync without XUserAddOptions::AddDefaultUserSilently to select a user. If a user is banned from XBOX Live, the game will not be able to get an XUserHandle for that user. If XUserAddOptions::AddDefaultUserSilently is used and the game was launched by a banned user, XUserAddResult will return E_GAMEUSER_NO_DEFAULT_USER. Otherwise, if UI is shown, either a non-banned user will need to sign-in, or the user will need to cancel out of the UI and XUserAddResult will return E_ABORT. You cannot use XUserAddOptions::AllowGuests with XUserAddOptions::AddDefaultUserSilently. A guest cannot be the default user. You can use XUserAddOptions::AllowGuests safely regardless of whether the current platform supports guests. You must close each XUserHandle handle that you retrieve from an XUsers API once by calling XUserCloseHandle. The following example demonstrates how to asynchronously add a user to a game session.Requirements
Header: XUser.h Library: xgameruntime.lib Supported platforms: Windows,Steam Deck, XBOX One family consoles and XBOX Series consolesConceptual documentation
- Run Microsoft Game Development Kit (GDK) API task
- Asynchronous programming design goals and improvements
