Uso della piattaforma di valutazione WaaS
Per usare l'API WaaS Assessment Platform, creare un'istanza dell'interfaccia IWaaSAssessor e quindi chiamare il metodo GetOSUpdateAssessment . In caso di esito positivo, il parametro risultato restituirà un oggetto OSUpdateAssessment , che conterrà le informazioni pertinenti.
Nell'esempio di codice seguente viene illustrato come recuperare una valutazione del sistema operativo dal sistema locale usando il metodo IWaaSAssessor.GetOSUpdateAssessment.
//
// 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;
}
}