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

# XblContextCreateHandle

> XblContextCreateHandle

Creates an XblContextHandle used to access XBOX services.

## Syntax

```cpp theme={null}
HRESULT XblContextCreateHandle(  
         XblUserHandle user,  
         XblContextHandle* context  
)  
```

### Parameters

*user*   \_In\_\
Type: XblUserHandle

The user associated with this XBOX services context.

*context*   \_Out\_\
Type: [XblContextHandle\*](https://docs.xbox.com/reference/live/xsapi-c/types_c/handles/xblcontexthandle.md)

Passes back the XBOX services context handle.

### Return value

Type: HRESULT

HRESULT return code for this API operation. Possible error codes include the following. This list isn't exhaustive.

| Return code | Description |
| - | - |
| S\_OK | The context was created. |
| E\_INVALIDARG | *user* or *context* is null. |
| E\_XBL\_NOT\_INITIALIZED | [XblInitialize](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_global_c/functions/xblinitialize.md) hasn't been called. |

## Remarks

Call this function after [XblInitialize](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_global_c/functions/xblinitialize.md) succeeds and the user has signed in. Create one context for each signed-in user. If more than one component needs the same context, call [XblContextDuplicateHandle](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_context_c/functions/xblcontextduplicatehandle.md) instead of creating a second context for the same user. Close every handle with [XblContextCloseHandle](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_context_c/functions/xblcontextclosehandle.md) when you no longer need it.

For an example, see [How to use XBOX services APIs](https://docs.xbox.com/services/xbox-services/fundamentals/xbox-services-api/live-gs-xbl-apis.md).

## Requirements

**Header:** xbox\_live\_context\_c.h

**Library:** Microsoft.Xbox.Services.142.C.lib or Microsoft.Xbox.Services.143.C.lib

## See also

[xbox\_live\_context\_c](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_context_c/xbox_live_context_c_members.md)


## Related topics

- [xbox_live_context_c (contents)](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_context_c/xbox_live_context_c_members.md)
- [XblAchievementsRemoveAchievementProgressChangeHandler](https://docs.xbox.com/reference/live/xsapi-c/achievements_c/functions/xblachievementsremoveachievementprogresschangehandler.md)
- [XblSocialRemoveSocialRelationshipChangedHandler](https://docs.xbox.com/reference/live/xsapi-c/social_c/functions/xblsocialremovesocialrelationshipchangedhandler.md)
- [XblPrivacyRemoveMuteListChangedHandler](https://docs.xbox.com/reference/live/xsapi-c/privacy_c/functions/xblprivacyremovemutelistchangedhandler.md)
- [XblPrivacyRemoveBlockListChangedHandler](https://docs.xbox.com/reference/live/xsapi-c/privacy_c/functions/xblprivacyremoveblocklistchangedhandler.md)
