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

# XSystemGetXboxLiveSandboxId

> XSystemGetXboxLiveSandboxId

# XSystemGetXboxLiveSandboxId

检索 XBOX Live 沙盒 ID。

## Syntax

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

### Parameters

*sandboxIdSize*   \_In\_\
类型：size\_t

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

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

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

*sandboxIdUsed*   \_Out\_opt\_\
类型：size\_t\*

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

### Return value

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

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

## Remarks

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

> [!NOTE]
>
> 沙盒 ID 区分大小写。

对于 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 主题）](https://docs.xbox.com/zh-CN/home/setup-install/dev-kit-settings/config-dev-kit-settings.md)\
[为 XBOX Live 开发设置沙盒](https://docs.xbox.com/zh-CN/services/xbox-services/fundamentals/sandboxes/live-setting-up-sandboxes.md)\
[XSystemGetConsoleId](https://docs.xbox.com/zh-CN/reference/system/xsystem/functions/xsystemgetconsoleid.md)\
[XSystem](https://docs.xbox.com/zh-CN/reference/system/xsystem/xsystem_members.md)


## Related topics

- [高级 XBOX 服务沙盒](https://docs.xbox.com/zh-CN/services/xbox-services/fundamentals/sandboxes/live-advanced-sandboxes.md)
- [确定主机所在地区](https://docs.xbox.com/zh-CN/build/game-principles/localization/determining-console-geolocation.md)
- [XSystem（API 内容）](https://docs.xbox.com/zh-CN/reference/system/xsystem/xsystem_members.md)
- [通过 Xbox Live ID 获取 PlayFab ID](https://docs.xbox.com/zh-CN/services/playfab/api-references/rest/server/account-management/get-playfab-ids-from-xbox-live-ids.md)
- [Get Title Players From Xbox Live IDs](https://docs.xbox.com/api-reference/account-management/get-title-players-from-xbox-live-ids.md)
