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

# XSystemGetXboxLiveSandboxId

> XSystemGetXboxLiveSandboxId

# XSystemGetXboxLiveSandboxId

检索 XBOX Live 沙盒 ID。

## Syntax

```cpp theme={null}
HRESULT XSystemGetXboxLiveSandboxId(  
         size_t sandboxIdSize,  
         char* sandboxId,  
         size_t* sandboxIdUsed  
)  
```

### Parameters

*sandboxIdSize*   \_In\_<br />类型：size\_t

*sandboxId* 的大小（以字节为单位）。此值必须大于或等于 XSystem.h 中定义的 **XSystemXboxLiveSandboxIdMaxBytes** 常量。

*sandboxId*   \_Out\_writes\_bytes\_to\_(sandboxIdSize,\*sandboxIdUsed)<br />类型：char\*

将接收沙盒 ID 的字符缓冲区。

*sandboxIdUsed*   \_Out\_opt\_<br />类型：size\_t\*

返回的 *sandboxId* 缓冲区的实际大小（以字节为单位）。

### Return value

类型：[HRESULT](https://learn.microsoft.com/openspecs/windows_protocols/ms-erref/0642cb2f-2075-4469-918c-4441e69c548a)

成功时返回 **S\_OK**；否则，返回错误代码。有关错误代码列表，请参阅[错误代码](/reference/errorcodes)。如果函数失败是因为 *sandboxIdSize* 设置的值小于 **XSystemXboxLiveSandboxIdMaxBytes**，则返回值将设置为 **HRESULT\_FROM\_WIN32(ERROR\_INSUFFICIENT\_BUFFER)**。

## Remarks

沙盒 ID 与 TitleID 和服务配置 ID (SCID) 一起，对 XBOX Live 主机游戏和应用程序的开发至关重要。沙盒 ID 用于标识你的沙盒，在开发期间为开发工具包提供内容隔离。内容隔离可确保你拥有一个用于开发和测试主机游戏的干净环境。

<Note>
  沙盒 ID 区分大小写。
</Note>

对于 XBOX 和 PC 设备，沙盒 ID 存储在设备上。如果找不到沙盒 ID，或者你没有访问沙盒 ID 的权限，则沙盒 ID 默认为“RETAIL”。

如果你的游戏实际上是在零售环境中运行，此函数也会返回“RETAIL”。

## Requirements

**头文件：** XSystem.h

**库：** xgameruntime.lib

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

## Conceptual documentation

* [时间敏感线程](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## See also

[配置开发工具包设置（NDA 主题）](/home/setup-install/dev-kit-settings/config-dev-kit-settings)<br />[为 XBOX Live 开发设置沙盒](/services/xbox-services/fundamentals/sandboxes/live-setting-up-sandboxes)<br />[XSystemGetConsoleId](/reference/system/xsystem/functions/xsystemgetconsoleid)<br />[XSystem](/reference/system/xsystem/xsystem_members)


## Related topics

- [确定主机所在地区](/zh-CN/build/game-principles/localization/determining-console-geolocation.md)
- [XSystem](/zh-CN/reference/system/xsystem/xsystem_members.md)
- [PFAccountManagementGetPlayFabIDsFromXboxLiveIDsRequest](/zh-CN/services/playfab/api-references/c/pfaccountmanagementtypes/structs/pfaccountmanagementgetplayfabidsfromxboxliveidsrequest.md)
- [PFAccountManagementGetTitlePlayersFromXboxLiveIDsRequest](/zh-CN/services/playfab/api-references/c/pfaccountmanagementtypes/structs/pfaccountmanagementgettitleplayersfromxboxliveidsrequest.md)
- [PartyXblGetEntityIdsFromXboxLiveUserIdsCompletedStateChange](/zh-CN/services/playfab/multiplayer/networking/xblreference/structs/partyxblgetentityidsfromxboxliveuseridscompletedstatechange.md)
