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

# XClosedCaptionSetEnabled

> XClosedCaptionSetEnabled

# XClosedCaptionSetEnabled

设置一个用于指示是否启用或禁用隐藏式字幕的布尔值。

## 语法

```cpp theme={null}
HRESULT XClosedCaptionSetEnabled(  
         bool enabled  
)  
```

### 参数

*enabled*   \_In\_\
类型：bool

用于指示是否启用或禁用隐藏式字幕的布尔值。

### 返回值

类型：HRESULT

成功时返回 HRESULT。否则返回错误代码。\
有关错误代码的列表，请参阅 [错误代码](https://docs.xbox.com/zh-CN/reference/errorcodes.md)。

## 备注

> [!NOTE]
>
> 此函数不能在时间敏感线程上安全调用。有关详细信息，请参阅 [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)。

要使此函数调用成功，必须启用隐藏式字幕。
用户必须在游戏 title 的 UI 中启用隐藏式字幕功能。

若要将隐藏式字幕标记为已启用，请将 *enabled* 设置为 true 或 1。
若要将隐藏式字幕标记为已禁用，请将 *enabled* 设置为 false 或 0。

以下示例演示了如何以编程方式启用隐藏式字幕。

```cpp theme={null}
//The user must first enable closed captions in the UI of the Game title. Afterwards, the game title can set the Boolean flag.
if (SUCCEEDED(XClosedCaptionsSetEnabled(true)))
{
    // Closed captions successfully enabled
}
```

## 要求

**头文件：** XAccessibility.h

**库：** xgameruntime.lib

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

## 概念性文档

* [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## 另请参阅

[XAccessibility](https://docs.xbox.com/zh-CN/reference/system/xaccessibility/xaccessibility_members.md)

[XClosedCaptionProperties](https://docs.xbox.com/zh-CN/reference/system/xaccessibility/structs/xclosedcaptionproperties.md)

[XClosedCaptionGetProperties](https://docs.xbox.com/zh-CN/reference/system/xaccessibility/functions/xclosedcaptiongetproperties.md)


## Related topics

- [XClosedCaptionGetProperties](https://docs.xbox.com/zh-CN/reference/system/xaccessibility/functions/xclosedcaptiongetproperties.md)
- [XSpeechToTextSetPositionHint](https://docs.xbox.com/zh-CN/reference/system/xaccessibility/functions/xspeechtotextsetpositionhint.md)
- [XSpeechToTextSendString](https://docs.xbox.com/zh-CN/reference/system/xaccessibility/functions/xspeechtotextsendstring.md)
- [XHighContrastGetMode](https://docs.xbox.com/zh-CN/reference/system/xaccessibility/functions/xhighcontrastgetmode.md)
- [Xbox 无障碍指南 104](https://docs.xbox.com/zh-CN/build/game-principles/accessibility/xag-deep-dives/xag-104-subtitles-captions.md)
