Skip to main content

XStoreCreateContext

Creates a store context for the specified user.

Syntax

Parameters

user   _In_opt_
Type: XUserHandle
The user to create the store context for.
This parameter is optional for PC games only: simply pass a nullptr value. On PC the user signed into the Microsoft Store is used automatically and this parameter is ignored. A valid XUser is required for console games.
storeContextHandle   _Out_
Type: XStoreContextHandle*
On success contains the created store context.

Return value

Type: HRESULT HRESULT success or error code.

Remarks

NOTE: On consoles, the XStoreContextHandle created by this function is invalidated after a Suspend or Quick Resume event. To safely handle these conditions we recommend closing a XStoreContextHandle and recreating it whenever the game resumes from a suspended state.
This function isn’t safe to call on a time-sensitive thread. For more information, see Time-sensitive threads.
When you are finished with the XStoreContextHandle created by this function, you must close it with XStoreCloseContextHandle. Failure to close the handle will cause a memory leak. The store context is used to identify the user to retrieve information for in a number of the XStore API calls. The following code snippet shows an example of creating a store context.

Requirements

Header: XStore.h (included in XGameRuntime.h) Library: xgameruntime.lib Supported platforms: Windows, XBOX One family consoles and XBOX Series consoles

Conceptual documentation

See also

XStore
XStoreCloseContextHandle
XStoreRegisterGameLicenseChanged
Last modified on August 20, 2026