IQueryAllWinSATAssessments::get_AllXML 方法 (winsatcominterfacei.h)

[IQueryAllWinSATAssessments::AllXML 可能会在Windows 8.1后对发布进行更改或不可用。]

使用指定的 XPath 从正式 XML 评估文档检索数据。 查询针对 WinSAT 数据存储中的所有正式评估运行。

此属性为只读。

语法

HRESULT get_AllXML(
  BSTR            xPath,
  BSTR            namespaces,
  IXMLDOMNodeList **ppDomNodeList
);

参数

xPath

namespaces

ppDomNodeList

返回值

备注

可以使用此方法检索通过 API 提供的摘要信息中不可用的评估详细信息。 有关评估中所有可用信息的详细信息,请参阅 WinSAT 架构

首次设置计算机时,将运行第一个正式评估。 在数据存储的生命周期内,初始评估将保留在数据存储中。 WinSAT 数据存储最多可以包含 100 个正式评估。 当存储达到容量时,WinSAT 将删除最旧的评估 (但不会删除数据存储中运行的每个新正式评估的初始评估) 。

WinSAT 数据存储仅包含正式评估。 如果要从临时评估中检索评估数据,则必须在运行评估时将结果保存到 XML 文件中, (查看 -xml 命令行参数了解详细信息) 。 然后,可以使用 IXMLDOMDocument2 接口的成员从临时评估中查询数据。

评估的返回顺序是任意的。

示例

以下示例演示如何使用 XPath 查询从评估存储中的每个正式评估获取数据。

#include <windows.h>
#include <stdio.h>
#include <comutil.h>
#include <winsatcominterfacei.h>

#pragma comment(lib, "comsupp.lib") // For _bstr_t

void main(void)
{
    HRESULT hr = S_OK;
    IQueryAllWinSATAssessments* pAssessment;
    IXMLDOMNodeList* pNodes = NULL;
    IXMLDOMNode* pMemory = NULL;
    IXMLDOMNode* pNode = NULL;
    _bstr_t bstrXPath = L"WinsatAssessments/WinSAT/SystemConfig/Memory";
    _bstr_t bstrAvailableRAM;
    _bstr_t bstrTotalRAM;

    hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);

    // Get an instance to the most recent formal assessment.
    hr = CoCreateInstance(__uuidof(CQueryAllWinSAT),
        NULL,
        CLSCTX_INPROC_SERVER,
        __uuidof(IQueryAllWinSATAssessments),
        (void**)&pAssessment);

    if (FAILED(hr))
    {
        wprintf(L"Failed to create an instance of IQueryAllWinSATAssessments. Failed with 0x%x.\n", hr);
        goto cleanup;
    }

    // Query the assessments for the memory nodes.
    hr = pAssessment->get_AllXML(bstrXPath, NULL, &pNodes);
    if (FAILED(hr))
    {
        wprintf(L"pAssessment->get_XML failed with 0x%x.\n", hr);
        goto cleanup;
    }

    hr = pNodes->nextNode(&pMemory);

    // Loop through the memory nodes and get available and total memory size
    // values and print them.
    while (pMemory)
    {
        hr = pMemory->selectSingleNode(L"TotalPhysical/Size", &pNode);
        if (FAILED(hr))
        {
            wprintf(L"pMemory->selectSingleNode(TotalPhysical/Size) failed with 0x%x.\n", hr);
            goto cleanup;
        }

        hr = pNode->get_text(bstrTotalRAM.GetAddress());
        if (FAILED(hr))
        {
            wprintf(L"pNode->get_text(bstrTotalRAM) failed with 0x%x.\n", hr);
            goto cleanup;
        }

        pNode->Release();
        pNode = NULL;

        hr = pMemory->selectSingleNode(L"AvailablePhysical/Size", &pNode);
        if (FAILED(hr))
        {
            wprintf(L"pMemory->selectSingleNode(AvailablePhysical/Size) failed with 0x%x.\n", hr);
            goto cleanup;
        }

        hr = pNode->get_text(bstrAvailableRAM.GetAddress());
        if (FAILED(hr))
        {
            wprintf(L"pNode->get_text(bstrAvailableRAM) failed with 0x%x.\n", hr);
            goto cleanup;
        }

        pNode->Release();
        pNode = NULL;

        wprintf(L"Available RAM: %s of %s\n", bstrAvailableRAM.GetBSTR(), bstrTotalRAM.GetBSTR());

        pMemory->Release();
        pMemory = NULL;

        hr = pNodes->nextNode(&pMemory);
    }

cleanup:

    if (pAssessment)
        pAssessment->Release();

    if (pNodes)
        pNodes->Release();

    if (pMemory)
        pMemory->Release();

    if (pNode)
        pNode->Release();

    CoUninitialize();
}

要求

   
最低受支持的客户端 Windows Vista [仅限桌面应用]
最低受支持的服务器 无受支持的版本
目标平台 Windows
标头 winsatcominterfacei.h
DLL Winsatapi.dll

另请参阅

IInitiateWinSATAssessment

IQueryAllWinSATAssessments

IQueryRecentWinSATAssessment::XML