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

# XClosedCaptionSetEnabled

> XClosedCaptionSetEnabled

# XClosedCaptionSetEnabled

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

## 语法

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

### 参数

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

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

### 返回值

类型：HRESULT

成功时返回 HRESULT。否则返回错误代码。\
有关错误代码的列表，请参阅 [错误代码](/reference/errorcodes)。

## 备注

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

要使此函数调用成功，必须启用隐藏式字幕。
用户必须在游戏 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](/reference/system/xaccessibility/xaccessibility_members)

[XClosedCaptionProperties](/reference/system/xaccessibility/structs/xclosedcaptionproperties)

[XClosedCaptionGetProperties](/reference/system/xaccessibility/functions/xclosedcaptiongetproperties)


## Related topics

- [XClosedCaptionGetProperties](/zh-CN/reference/system/xaccessibility/functions/xclosedcaptiongetproperties.md)
- [XSpeechToTextSetPositionHint](/zh-CN/reference/system/xaccessibility/functions/xspeechtotextsetpositionhint.md)
- [XSpeechToTextSendString](/zh-CN/reference/system/xaccessibility/functions/xspeechtotextsendstring.md)
- [XHighContrastGetMode](/zh-CN/reference/system/xaccessibility/functions/xhighcontrastgetmode.md)
- [XAG 104：字幕与隐藏字幕](/zh-CN/build/game-principles/accessibility/xag-deep-dives/xag-104-subtitles-captions.md)
