Windows Update Agent API 检查系统补丁安装情况的函数

来源:互联网 发布:美国大学录取数据 编辑:程序博客网 时间:2024/05/22 11:16

IUpdateSearcher interface

 

We are using the WUA to detect missing windows updates. The
problem is that not all categories are returned. Comparing the result
from the WUA with the result from the update.microsoft.com is different.
For example the update.microsoft.com site shows a category called
"Microsoft Office 2003" which is not returned by the WUA.

Here is the code we are using:

CoInitialize(NULL);IUpdateSession* pUpdateSession = NULL;IUpdateServiceManager* pUpdateServiceManager = NULL;IUpdateService* pUpdateService = NULL;IUpdateSearcher* pUpdateSearcher = NULL;m_errorScan = failure;do{// create update session object.Log(llTrace, (CPString)L"Windows Update Scan : Create update session object");HRESULT hr = CoCreateInstance ( CLSID_UpdateSession, NULL, CLSCTX_INPROC_SERVER, IID_IUpdateSession, (void**) &pUpdateSession );if ( FAILED(hr) || pUpdateSession == NULL ){break;}// create update service manager object.Log(llTrace, (CPString)L"Windows Update Scan : Create update service manager object");hr = CoCreateInstance ( CLSID_UpdateServiceManager, NULL, CLSCTX_INPROC_SERVER, IID_IUpdateServiceManager, (void**) &pUpdateServiceManager );if ( FAILED(hr) || pUpdateServiceManager == NULL ){break;}// create update searcher object.Log(llTrace, (CPString)L"Windows Update Scan : Create update searcher object");hr = pUpdateSession->CreateUpdateSearcher(&pUpdateSearcher);if ( FAILED(hr) || pUpdateSearcher == NULL ){break;}// select the update server source.Log(llTrace, (CPString)L"Windows Update Scan : Select the update server source");hr = pUpdateSearcher->put_ServerSelection(ssWindowsUpdate);hr = pUpdateSearcher->put_CanAutomaticallyUpgradeService(VARIANT_TRUE);hr = pUpdateSearcher->put_IncludePotentiallySupersededUpdates(VARIANT_TRUE);hr = pUpdateSearcher->put_Online(VARIANT_TRUE);ISearchResult* pSearchResult = NULL;Log(llTrace, (CPString)L"Windows Update Scan : Start search");hr = pUpdateSearcher->Search(BSTR(L"IsInstalled = 0"), &pSearchResult);if ( FAILED(hr) || pSearchResult == NULL ){break;}// retrive and write the category collection content.ICategoryCollection* pCategoryCollection = NULL;hr = pSearchResult->get_RootCategories(&pCategoryCollection);if ( FAILED(hr) || pCategoryCollection == NULL ){break;}else{WriteCategoryCollection(pCategoryCollection, m_aWindowsUpdateCategories);}LONG count = 0;HRESULT hr = pCategoryCollection->get_Count(&count);if(FAILED(hr)){return eCreationErr;}for(int i = 0; i < count; i++){ICategory* pCategory = NULL;hr = pCategoryCollection->get_Item(i, &pCategory);if(FAILED(hr)){continue;}...

Are there any informations about that ?