Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
  2.  
  3. ISearchResult *pResult;
  4. IUpdateSession *pSession;
  5. IUpdateSearcher *pSearcher;
  6.  
  7. CoCreateInstance(CLSID_UpdateSession, NULL, CLSCTX_INPROC_SERVER, IID_IUpdateSession, (LPVOID*)&pSession);
  8. pSession->CreateUpdateSearcher(&pSearcher);
  9.  
  10. LONG updateSizeT, updateSizeB1, updateSizeB0;
  11. IUpdateCollection *pCollection;
  12.  
  13. BSTR criteria = SysAllocString(L"IsInstalled=0");
  14. pSearcher->Search(criteria, &pResult);
  15. pResult->get_Updates(&pCollection);
  16. pCollection->get_Count(&updateSizeT);
  17.  
  18. SysFreeString(criteria);
  19. criteria = SysAllocString(L"IsInstalled=0 and BrowseOnly=0");
  20. pSearcher->Search(criteria, &pResult);
  21. pResult->get_Updates(&pCollection);
  22. pCollection->get_Count(&updateSizeB0);
  23.  
  24. SysFreeString(criteria);
  25. criteria = SysAllocString(L"IsInstalled=0 and BrowseOnly=1");
  26. pSearcher->Search(criteria, &pResult);
  27. pResult->get_Updates(&pCollection);
  28. pCollection->get_Count(&updateSizeB1);
  29.  
  30. SysFreeString(criteria);
  31. wcout << L"Total: " << updateSizeT << endl
  32. << L"BrowseOnly=0: " << updateSizeB0 << endl
  33. << L"BrowseOnly=1: " << updateSizeB1 << endl;
  34.  
  35. Total: 86
  36. BrowseOnly=0: 49
  37. BrowseOnly=1: 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement