3

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.

damadzic
  • 43
  • 3

1 Answers1

0

This is normal behaviour and I think that you might be searching for updates on a new Windows 7 VM.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – CapTen101 Dec 02 '21 at 19:57