您可以IAutomaticUpdatesResults*
从IAutomaticUpdates2::get_Results
.
IAutomaticUpdates2
是由 AutomaticUpdates coclass 实现的接口。
完整样本:
#include <Windows.h>
#include <wuapi.h>
#include <iostream>
int main() {
HRESULT hr;
hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
if(FAILED(hr))
return hr;
IAutomaticUpdates2* iupdates = nullptr;
hr = CoCreateInstance(
CLSID_AutomaticUpdates,
nullptr,
CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER | CLSCTX_INPROC_SERVER,
IID_PPV_ARGS(&iupdates)
);
IAutomaticUpdatesResults* results = nullptr;
if(SUCCEEDED(hr)) {
hr = iupdates->get_Results(&results);
}
DATE lastSearchSuccessDate = 0.0;
if(SUCCEEDED(hr)) {
VARIANT var;
VariantInit(&var);
hr = results->get_LastSearchSuccessDate(&var);
lastSearchSuccessDate = var.date;
}
if(SUCCEEDED(hr)) {
std::cout << lastSearchSuccessDate << std::endl;
}
if(results)
results->Release();
if(iupdates)
iupdates->Release();
CoUninitialize();
return hr;
}