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

# XtfCloseConsoleInfoList

> XtfCloseConsoleInfoList

# XtfCloseConsoleInfoList

释放与 [XtfGetConsoleInfoList](/reference/tools/xtf/xtfconsolecontrol/functions/xtfgetconsoleinfolist-xtfconsolecontrol-xbox-microsoft-m) 返回的 **XtfConsoleInfo** 对象关联的资源。

## 语法

```cpp theme={null}
HRESULT XtfCloseConsoleInfoList(
         XtfConsoleInfo hConsoleInfo
)  
```

### 参数

*hConsoleInfo*\
类型：XtfConsoleInfo

\[in] 要释放的 XtfConsoleInfo 对象。

### 返回值

类型：HRESULT

返回值为 S\_OK 表示函数成功。其他任何值都表示发生了意外错误。

## 备注

使用 [XtfGetConsoleInfoList](/reference/tools/xtf/xtfconsolecontrol/functions/xtfgetconsoleinfolist-xtfconsolecontrol-xbox-microsoft-m) 获取一个 **XtfConsoleInfo** 对象，然后使用 [XtfGetConsoleFieldValue](/reference/tools/xtf/xtfapi/functions/xtfgetconsolefieldvalue-xbox-microsoft-m) 从该对象中检索值。检索到所需的值后，使用 [XtfCloseConsoleInfoList](/reference/tools/xtf/xtfapi/functions/xtfcloseconsoleinfolist-xbox-microsoft-m) 释放与返回的 **XtfConsoleInfo** 对象关联的资源。

<Note>**XtfGetConsoleInfoList** 会从主机检索所有信息。[XtfGetConsoleFieldValue](/reference/tools/xtf/xtfapi/functions/xtfgetconsolefieldvalue-xbox-microsoft-m) 只是遍历该已检索的信息。</Note>

<Note>如果目标主机尚未配置，**DeviceID** 将返回一个空值。</Note>

```cpp theme={null}
int wmain(int argc, wchar_t **argv)
{
  HRESULT             hr             = S_OK;
  PCWSTR              consoleAddress = L" 190.167.10.18";
  XtfConsoleInfo      hConsoleInfo   = nullptr;
  XtfConsoleFieldType fieldType      = XtfConsoleFieldType::FieldTypeUINT32;
  BYTE *              pValueBuffer   = nullptr;
  UINT32              bufferSize     = 0;

  hr = XtfGetConsoleInfoList(consoleAddress, &hConsoleInfo);
  if (FAILED(hr))
  {
    wprintf(L"\n\n*** XtfGetConsoleInfoList failed 0x%x", hr);
    return hr;
  }

  hr = XtfGetConsoleFieldValue(hConsoleInfo, XtfConsoleFieldId::ConsoleId, &fieldType, nullptr, &bufferSize);
  if (hr != HRESULT_FROM_WIN32(ERROR_MORE_DATA))
  {
    XtfCloseConsoleInfoList(hConsoleInfo);
    wprintf(L"\n\n*** XtfGetConsoleFieldValue failed 0x%x", hr);
    return hr;
  }

  pValueBuffer = new BYTE[bufferSize];

  hr  = XtfGetConsoleFieldValue(hConsoleInfo, XtfConsoleFieldId::ConsoleId, &fieldType, pValueBuffer, &bufferSize);
  if (SUCCEEDED(hr))
  {
    PWCHAR consoleId = (PWCHAR)pValueBuffer;
    wprintf(L"\n\n*** Console ID is %s", consoleId);
  }
  else
  {
    wprintf(L"\n\n*** XtfGetConsoleFieldValue failed 0x%x", hr);
  }

  XtfCloseConsoleInfoList(hConsoleInfo);
  delete[] pValueBuffer;

  return hr;
}  
```

## 要求

**头文件：** xtfapi.h

**库：** XtfApi.lib

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

## 另请参阅

[XTF 传输错误 (NDA 主题)](/tools/tools-console/commandlinetools/xtf-transport-errors)\
[其他 Xtf API](/reference/tools/xtf/xtfapi/atoc-xtfapi)


## Related topics

- [XtfGetConsoleFieldValue](/zh-CN/reference/tools/xtf/xtfapi/functions/xtfgetconsolefieldvalue-xbox-microsoft-m.md)
- [XtfGetConsoleInfoList](/zh-CN/reference/tools/xtf/xtfconsolecontrol/functions/xtfgetconsoleinfolist-xtfconsolecontrol-xbox-microsoft-m.md)
- [XtfCloseCredentialInfoList](/zh-CN/reference/tools/xtf/xtfapi/functions/xtfclosecredentialinfo-xtfapi-xbox-windows-m.md)
- [XtfGetCredentialInfoList](/zh-CN/reference/tools/xtf/xtfapi/functions/xtfgetcredentialinfolist-xtfapi-xbox-windows-m.md)
- [XtfGetCredentialInfoCount](/zh-CN/reference/tools/xtf/xtfapi/functions/xtfgetcredentialinfocount-xtfapi-xbox-windows-m.md)
