使用 WaaS 评估平台
若要使用 WaaS 评估平台 API,请创建 IWaaSAssessor 接口的实例,然后调用 GetOSUpdateAssessment 方法。 成功后, result 参数将输出 OSUpdateAssessment 对象,该对象将包含相关信息。
以下代码示例演示如何使用 IWaaSAssessor.GetOSUpdateAssessment 方法从本地系统检索 OS 评估。
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
#include <windows.h>
#include <tchar.h>
#include <oaidl.h>
#include <atlbase.h>
#include <iostream>
#include <WaaSAPI.h>
#include <WaaSAPITypes.h>
using namespace std;
void __cdecl main(int argc, char** argv)
{
HRESULT hr = S_OK;
CComPtr<IWaaSAssessor> assessment;
OSUpdateAssessment result;
hr = CoInitialize(NULL);
if (SUCCEEDED(hr))
{
hr = CoCreateInstance(
__uuidof(WaaSAssessor), // rclsid
NULL, // pUnkOuter
CLSCTX_INPROC_SERVER, // dwClsContext
__uuidof(IWaaSAssessor), // riid
(LPVOID*)&assessment); // ppv
if (SUCCEEDED(hr))
{
hr = assessment->GetOSUpdateAssessment(&result);
if (SUCCEEDED(hr))
{
wcout << L"End of Support:" << result.isEndOfSupport << endl;
wcout << L"Up to date:" << result.assessmentForUpToDate.status << endl;
wcout << L"Current:" << result.assessmentForCurrent.status << endl;
wcout << L"Up to Date Days Behind:" << result.assessmentForUpToDate.daysOutOfDate << endl;
wcout << L"Current Days Behind:" << result.assessmentForCurrent.daysOutOfDate << endl;
wcout << L"Up to Date Impact:" << result.assessmentForUpToDate.impact << endl;
wcout << L"Current Impact:" << result.assessmentForCurrent.impact << endl;
}
else
{
wcout << L"Assessment Failed hr = " << hr << endl;
}
}
else
{
wcout << L"CoCreateInstance Failed hr = " << hr << endl;
}
}
else
{
wcout << L"CoInitialize Failed hr = " << hr << endl;
}
}