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

# XAppCaptureRecordDiagnosticClip

> XAppCaptureRecordDiagnosticClip

# XAppCaptureRecordDiagnosticClip

从应用中录制一个诊断剪辑。

## Syntax

```cpp theme={null}
HRESULT XAppCaptureRecordDiagnosticClip(  
         time_t startTime,  
         uint32_t durationInMs,  
         const char* filenamePrefix,  
         XAppCaptureRecordClipResult* result  
)  
```

### Parameters

*startTime*   \_In\_\
类型：time\_t

诊断剪辑开始时的时间戳。

*durationInMs*   \_In\_\
类型：uint32\_t

诊断剪辑的持续时间（以毫秒为单位）。

*filenamePrefix*   \_In\_opt\_\
类型：char\*

文件名的所需前缀，可选，将附加到诊断文件名的开头。

*result*   \_Out\_\
类型：[XAppCaptureRecordClipResult\*](/reference/system/xappcapture/structs/xappcapturerecordclipresult)

生成的已录制诊断剪辑。

### Return value

类型：HRESULT

函数结果。

## Remarks

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

调用此函数不会触发 UI 通知。剪辑保存到游戏可访问的分区。[XAppCaptureRecordDiagnosticClipResult](/reference/system/xappcapture/structs/xappcapturerecordclipresult) 包含一个可用于访问剪辑的文件路径。
在 XBOX 上，此函数仅在开发工具包中可用。在零售工具包上，此 API 会立即返回错误。

在 PC 上，你必须为应用启用后台录制才能使此函数正常工作。执行此操作的最佳方法是按 Win+G 调出 Game Bar，然后单击"设置"图标，转到"捕获"选项卡，并启用"当我玩游戏时在后台录制"。
然后，必须将应用标记为游戏。执行此操作的最佳方法是先运行游戏。当游戏处于焦点状态时，按 Win+G 调出 Game Bar，然后单击"设置"图标，转到"常规"选项卡，并选中"记住这是一款游戏"。

## Requirements

**头文件：** XAppCapture.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

[GameDVR 概述](/build/console-features/game-dvr/gamedvr-broadcast)\
[XAppCapture Members](/reference/system/xappcapture/xappcapture_members)\
[XAppCaptureRecordDiagnosticClipResult](/reference/system/xappcapture/structs/xappcapturerecordclipresult)


## Related topics

- [XAppCaptureRecordClipResult](/zh-CN/reference/system/xappcapture/structs/xappcapturerecordclipresult.md)
- [XAppCapture](/zh-CN/reference/system/xappcapture/xappcapture_members.md)
- [面向 GDK 的 Unity C# API 包装器](/zh-CN/build/gdk-and-engines/unity/unity-api-wrappers.md)
- [XAppCaptureVideoEncoding](/zh-CN/reference/system/xappcapture/enums/xappcapturevideoencoding.md)
- [XAppCaptureUserRecordingResult](/zh-CN/reference/system/xappcapture/structs/xappcaptureuserrecordingresult.md)
