I am trying to collect not already installed, non optional Windows Updates for a machine via IUpdateSearcher, similar to this question.
IUpdateSearchers documentation states the updates could be filtered via the BrowseOnly criterion. Yet it does not seem to work for me, this code:
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
ISearchResult *pResult;
IUpdateSession *pSession;
IUpdateSearcher *pSearcher;
CoCreateInstance(CLSID_UpdateSession, NULL, CLSCTX_INPROC_SERVER, IID_IUpdateSession, (LPVOID*)&pSession);
pSession->CreateUpdateSearcher(&pSearcher);
LONG updateSizeT, updateSizeB1, updateSizeB0;
IUpdateCollection *pCollection;
BSTR criteria = SysAllocString(L"IsInstalled=0");
pSearcher->Search(criteria, &pResult);
pResult->get_Updates(&pCollection);
pCollection->get_Count(&updateSizeT);
SysFreeString(criteria);
criteria = SysAllocString(L"IsInstalled=0 and BrowseOnly=0");
pSearcher->Search(criteria, &pResult);
pResult->get_Updates(&pCollection);
pCollection->get_Count(&updateSizeB0);
SysFreeString(criteria);
criteria = SysAllocString(L"IsInstalled=0 and BrowseOnly=1");
pSearcher->Search(criteria, &pResult);
pResult->get_Updates(&pCollection);
pCollection->get_Count(&updateSizeB1);
SysFreeString(criteria);
wcout << L"Total: " << updateSizeT << endl
<< L"BrowseOnly=0: " << updateSizeB0 << endl
<< L"BrowseOnly=1: " << updateSizeB1 << endl;
Produces the following output:
Total: 86
BrowseOnly=0: 49
BrowseOnly=1: 0
Other than the code being ugly, what am I doing wrong?
Even more checking the Windows Update Control Panel shows there should be 0 non-optional (BrowseOnly=0) updates, yet the codes returns 49.