I am using IUpdateSession
and IUpdateSearcher
in an attempt to get a list of available updates for a Windows system.
hr = CoCreateInstance(CLSID_UpdateSession, NULL, CLSCTX_INPROC_SERVER, IID_IUpdateSession, (void**)&pUpdateSession);
if (FAILED(hr) || pUpdateSession == NULL)
{
return;
}
hr = pUpdateSession->CreateUpdateSearcher(&pUpdateSearcher);
if (FAILED(hr) || pUpdateSearcher == NULL)
{
return;
}
pUpdateSearcher->put_Online(VARIANT_FALSE);
pUpdateSearcher->put_CanAutomaticallyUpgradeService(VARIANT_FALSE);
pUpdateSearcher->put_IncludePotentiallySupersededUpdates(VARIANT_FALSE);
hr = pUpdateSearcher->Search(BSTR(L"IsInstalled=0 AND IsHidden=0"), &type);
if (FAILED(hr) || type == NULL)
{
return;
}
else
{
... Print results etc. etc.
}
This works great when you have a single (or small number) of updates. When testing on a fresh machine with 109 updates available, the ->Search()
call takes over 10 minutes to process.
Is this normal behaviour, or is there something that can be done to improve the performance?
Thanks in advance for any help. Other solutions to achieve a list of available updates also welcome.