> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Initialize

> 初始化保存游戏包装器，并同步指定用户的所有容器。

# Microsoft.Xbox.Wrappers.XGameSave.Provider.Initialize

初始化保存游戏包装器，并同步指定用户的所有容器。

<a id="syntaxSection" />

## 语法

```cpp theme={null}
HRESULT Initialize(XUserHandle userHandle,
                   const std::string& serviceConfigurationId);
```

<a id="parametersSection" />

### 参数

*userHandle*   \_In\_<br />类型：XUserHandle

XBOX Live 用户账户的句柄。

*serviceConfigurationId*  \_In\_<br />类型：std::string

游戏的服务配置 ID (SCID)。

<a id="retvalSection" />

### 返回值

类型：HRESULT

此方法在成功时返回 **S\_OK**，在失败时返回以下 HRESULT 代码：

* **E\_GS\_USER\_CANCELED**
* **E\_GS\_USER\_NOT\_REGISTERED\_IN\_SERVICE**
* **E\_GS\_NO\_ACCESS**
* **E\_GS\_NO\_SERVICE\_CONFIGURATION**

<a id="remarksSection" />

## 备注

必须先调用此方法，然后才能调用 `Provider` 类中的任何其他方法。

不应在游戏的 UI 线程上调用此方法，因为它可能会阻塞，并且在同步用户的游戏存档时可能会向用户显示 UI。

若要从指定容器中加载给定 Blob 的数据，请调用 [Load](/reference/system/Wrappers/classes/provider/methods/xgamesave_wrapper_provider_load)。

<a id="requirementsSection" />

## 要求

**标头：** xgamesavewrappers.hpp

**支持的平台：** Windows、XBOX One 系列主机和 XBOX Series 主机

<a id="seealsoSection" />

## 另请参阅

[Microsoft.Xbox.Wrappers.XGameSave.Provider](/reference/system/Wrappers/classes/provider/xgamesave_wrapper_provider)<br />[XGameSave 包装器成员](/reference/system/Wrappers/xgamesave_wrapper_members)


## Related topics

- [HCInitialize](/zh-CN/reference/live/httpclient/httpclient/functions/hcinitialize.md)
- [PFInitialize](/zh-CN/services/playfab/api-references/c/pfcore/functions/pfinitialize.md)
- [XblInitialize](/zh-CN/reference/live/xsapi-c/xbox_live_global_c/functions/xblinitialize.md)
- [chat_manager::initialize](/zh-CN/reference/chat/gamechat2/classes/chat_manager/methods/chat_manager_initialize.md)
- [PFServicesInitialize](/zh-CN/services/playfab/api-references/c/pfservices/functions/pfservicesinitialize.md)
