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

# XblInitialize

> XblInitialize

Initializes the library instance.

## Syntax

```cpp theme={null}
HRESULT XblInitialize(  
         const XblInitArgs* args  
)  
```

### Parameters

*args*   \_In\_\
Type: [XblInitArgs\*](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_global_c/structs/xblinitargs.md)

Platform-specific args for XblInitialize.

### 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 library was initialized. |
| E\_INVALIDARG | *args* is null, or *args->scid* is null or empty. |
| E\_NO\_TASK\_QUEUE | *args->queue* is null and no process task queue is available. |
| E\_XBL\_ALREADY\_INITIALIZED | The library is already initialized. |

## Remarks

Call [XGameRuntimeInitialize](https://docs.xbox.com/reference/system/xgameruntimeinit/functions/xgameruntimeinitialize.md) before you call this function. Call this function before any other Xbl\* function, except for [XblMemSetFunctions](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_global_c/functions/xblmemsetfunctions.md) and [XblMemGetFunctions](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_global_c/functions/xblmemgetfunctions.md).

Call this function once for each instance of the XSAPI library that you link. Don't call it again until [XblCleanupAsync](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_global_c/functions/xblcleanupasync.md) completes. If you statically link XSAPI into more than one DLL, each DLL has its own copy of the XSAPI state, and calling `XblInitialize` in one DLL doesn't initialize XSAPI in the others. To share one XSAPI instance across DLLs, use `Microsoft.Xbox.Services.C.Thunks.dll`.

If you set custom memory functions with `XblMemSetFunctions`, call `XblCleanupAsync` and wait for it to finish before you shut down your memory manager.

After this function succeeds, create an XBOX services context for each signed-in user by calling [XblContextCreateHandle](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_context_c/functions/xblcontextcreatehandle.md). For more information, 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\_global\_c.h

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

## See also

[xbox\_live\_global\_c](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_global_c/xbox_live_global_c_members.md)


## Related topics

- [HCInitialize](https://docs.xbox.com/reference/live/httpclient/httpclient/functions/hcinitialize.md)
- [Troubleshooting Sign-in and Sandbox Errors](https://docs.xbox.com/services/xbox-services/develop/troubleshooting/live-troubleshoot-sandboxes.md)
- [XblInitArgs](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_global_c/structs/xblinitargs.md)
- [XblGetScid](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_global_c/functions/xblgetscid.md)
- [XblLocalStorageSetHandlers](https://docs.xbox.com/reference/live/xsapi-c/platform_c/functions/xbllocalstoragesethandlers.md)
