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

# XAppCaptureTakeDiagnosticScreenshot

> XAppCaptureTakeDiagnosticScreenshot

# XAppCaptureTakeDiagnosticScreenshot

从应用截取一张诊断屏幕截图。

## Syntax

```cpp theme={null}
HRESULT XAppCaptureTakeDiagnosticScreenshot(  
         bool gamescreenOnly,  
         XAppCaptureScreenshotFormatFlag captureFlags,  
         const char* filenamePrefix,  
         XAppCaptureDiagnosticScreenshotResult* result  
)  
```

### Parameters

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

决定是否只捕获游戏画面。如果设置为 false，除了游戏画面外，可能还会捕获某些 UI，如屏幕键盘。

*captureFlags*   \_In\_\
类型：[XAppCaptureScreenshotFormatFlag](https://docs.xbox.com/zh-CN/reference/system/xappcapture/enums/xappcapturescreenshotformatflag.md)

决定捕获将采用 SDR 还是 HDR。

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

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

*result*   \_Out\_\
类型：[XAppCaptureDiagnosticScreenshotResult\*](https://docs.xbox.com/zh-CN/reference/system/xappcapture/structs/xappcapturediagnosticscreenshotresult.md)

生成的已捕获屏幕截图。

### Return value

类型：HRESULT

函数结果。

## Remarks

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

与 [XAppCaptureTakeScreenshot](https://docs.xbox.com/zh-CN/reference/system/xappcapture/functions/xappcapturetakescreenshot.md) 不同，调用此函数不会触发 UI 通知。**XAppCaptureTakeDiagnosticScreenshot** 使用 [XAppCaptureScreenshotFormatFlag](https://docs.xbox.com/zh-CN/reference/system/xappcapture/enums/xappcapturescreenshotformatflag.md) 来指定屏幕捕获将采用 SDR、HDR 还是两者。但是，仍必须以 HDR 运行才能进行 HDR 捕获。屏幕截图保存到游戏可访问的分区。[XAppCaptureDiagnosticScreenshotResult](https://docs.xbox.com/zh-CN/reference/system/xappcapture/structs/xappcapturediagnosticscreenshotresult.md) 包含一个 [XAppCaptureScreenshotFile](https://docs.xbox.com/zh-CN/reference/system/xappcapture/structs/xappcapturescreenshotfile.md) 数组，每个结构体都包含一个屏幕截图的文件路径。

此函数仅在开发工具包中可用。在零售工具包上，此 API 会立即返回错误。

## 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 概述](https://docs.xbox.com/zh-CN/build/console-features/game-dvr/gamedvr-broadcast.md)\
[XAppCapture Members](https://docs.xbox.com/zh-CN/reference/system/xappcapture/xappcapture_members.md)\
[XAppCaptureDiagnosticScreenshotResult](https://docs.xbox.com/zh-CN/reference/system/xappcapture/structs/xappcapturediagnosticscreenshotresult.md)\
[XAppCaptureScreenshotFormatFlag](https://docs.xbox.com/zh-CN/reference/system/xappcapture/enums/xappcapturescreenshotformatflag.md)\
[XAppCaptureDiagnosticScreenshotResult](https://docs.xbox.com/zh-CN/reference/system/xappcapture/structs/xappcapturediagnosticscreenshotresult.md)\
[XAppCaptureScreenshotFile](https://docs.xbox.com/zh-CN/reference/system/xappcapture/structs/xappcapturescreenshotfile.md)


## Related topics

- [XAppCaptureDiagnosticScreenshotResult](https://docs.xbox.com/zh-CN/reference/system/xappcapture/structs/xappcapturediagnosticscreenshotresult.md)
- [XAppCaptureScreenshotFile](https://docs.xbox.com/zh-CN/reference/system/xappcapture/structs/xappcapturescreenshotfile.md)
- [XAppCaptureScreenshotFormatFlag](https://docs.xbox.com/zh-CN/reference/system/xappcapture/enums/xappcapturescreenshotformatflag.md)
- [XAppCapture（API 内容）](https://docs.xbox.com/zh-CN/reference/system/xappcapture/xappcapture_members.md)
- [在 Unity 项目中使用 GDK API 的 C# 包装器](https://docs.xbox.com/zh-CN/build/gdk-and-engines/unity/unity-api-wrappers.md)
