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

# XtfCaptureOutputBegin

> XtfCaptureOutputBegin

# XtfCaptureOutputBegin

开始捕获调试输出。

## 语法

```cpp theme={null}
void XtfCaptureOutputBegin(
         PCWSTR address,
         XtfDebugStringCallback debugStringCallback,
         XtfDebugStringErrorCallback debugStringErrorCallback,
         PVOID context,
         PHANDLE hListen
)  
```

### 参数

*address*\
类型：PCWSTR

\[in] 主机的 IP 地址。

*debugStringCallback*\
类型：[XtfDebugStringCallback](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfapi/functions/xtfdebugstringcallback-xtfapi-xbox-windows-m.md)

\[in, optional] 针对每个输出调试字符串调用的可选回调。

*debugStringErrorCallback*\
类型：[XtfDebugStringErrorCallback](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfapi/functions/xtfdebugstringerrorcallback-xtfapi-xbox-windows-m.md)

\[in, optional] 针对遇到的每个错误调用的可选回调。

*context*\
类型：PVOID

\[in, optional] 一个指向对象的指针，该对象会被传入回调函数。此对象允许每次回调调用与此次捕获会话相关联。

*hListen*\
类型：PHANDLE

\[out] 表示此次捕获会话的句柄。

### 返回值

无。

## 备注

使用此函数和 [XtfCaptureOutputEnd](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfapi/functions/xtfcaptureoutputend-xtfapi-xbox-windows-m.md) 函数来开始和停止捕获来自开发主机的一般调试输出。如果你想监视开发主机上特定进程 ID 的调试输出，请使用调试监视客户端。有关使用调试监视客户端的更多信息，请参阅 [XtfCreateDebugMonitorClient](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfdebugmonitor/methods/xtfcreatedebugmonitorclient-xtfdebugmonitor-xbox-microsoft-m.md)。

如果希望在捕获会话中捕获调试字符串，则必须实现并在 `debugStringCallback` 中指定一个 `XtfDebugStringCallback` 函数。同样，若要捕获捕获会话期间遇到的错误，必须实现并在 `debugStringErrorCallback` 中指定一个 `XtfDebugStringErrorCallback` 函数。但这两个回调函数都不是必需的。

若要停止捕获调试输出并释放与捕获会话关联的资源，请调用 [XtfCaptureOutputEnd](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfapi/functions/xtfcaptureoutputend-xtfapi-xbox-windows-m.md) 并指定为该捕获会话在 `hListen` 中返回的句柄。

> [!NOTE]
>
> 你必须调用 `XtfCaptureOutputEnd` 来停止捕获会话。否则，该捕获会话会成为孤立会话，与之关联的资源不会被释放，从而导致内存泄漏。

## 要求

**头文件：** xtfapi.h

**库：** XtfApi.lib

**支持的平台：** Windows（用于 XBOX 主机工具）

## 另请参阅

[IXtfDebugMonitorClient 接口](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfdebugmonitor/classes/IXtfDebugMonitorClient/ixtfdebugmonitorclient-xtfdebugmonitor-xbox-microsoft-t.md)\
[XTF 传输错误 (NDA 主题)](https://docs.xbox.com/zh-CN/tools/tools-console/commandlinetools/xtf-transport-errors.md)\
[其他 Xtf API](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfapi/atoc-xtfapi.md)


## Related topics

- [XtfCaptureOutputEnd](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfapi/functions/xtfcaptureoutputend-xtfapi-xbox-windows-m.md)
- [其他 Xtf API（API 内容）](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfapi/atoc-xtfapi.md)
- [XtfDebugStringErrorCallback](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfapi/functions/xtfdebugstringerrorcallback-xtfapi-xbox-windows-m.md)
- [XtfDebugStringCallback](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfapi/functions/xtfdebugstringcallback-xtfapi-xbox-windows-m.md)
- [IXtfDebugMonitorClient 接口（接口内容）](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfdebugmonitor/classes/IXtfDebugMonitorClient/ixtfdebugmonitorclient-xtfdebugmonitor-xbox-microsoft-t.md)
