C++ 使用wuapi获取Windows系统更新
在我的应用程序中,我显示windows计算机是否有可用的更新,这些更新应与“windows Update”设置相同。我使用的是这样的代码,它通常是有效的C++ 使用wuapi获取Windows系统更新,c++,windows,winapi,windows-update,C++,Windows,Winapi,Windows Update,在我的应用程序中,我显示windows计算机是否有可用的更新,这些更新应与“windows Update”设置相同。我使用的是这样的代码,它通常是有效的 #include "stdafx.h" #include <wuapi.h> #include <iostream> #include <ATLComTime.h> #include <wuerror.h> using namespace std; int _tmain(int argc,
#include "stdafx.h"
#include <wuapi.h>
#include <iostream>
#include <ATLComTime.h>
#include <wuerror.h>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
HRESULT hr;
hr = CoInitialize(NULL);
IUpdateSession* iUpdate;
IUpdateSearcher* searcher;
ISearchResult* results;
BSTR criteria = SysAllocString(L"IsInstalled=0 and IsHidden=0");
hr = CoCreateInstance(CLSID_UpdateSession, NULL, CLSCTX_INPROC_SERVER, IID_IUpdateSession, (LPVOID*)&iUpdate);
hr = iUpdate->CreateUpdateSearcher(&searcher);
wcout << L"Searching for updates ..."<<endl;
hr = searcher->Search(criteria, &results);
SysFreeString(criteria);
//...
}
#包括“stdafx.h”
#包括
#包括
#包括
#包括
使用名称空间std;
int _tmain(int argc,_TCHAR*argv[]
{
HRESULT-hr;
hr=协同初始化(空);
IUpdateSession*iUpdate;
IUpdateSearcher*搜索者;
ISearchResult*结果;
BSTR标准=系统分配字符串(L“IsInstalled=0,IsHidden=0”);
hr=CoCreateInstance(CLSID_UpdateSession,NULL,CLSCTX_INPROC_服务器,IID_IUpdateSession,(LPVOID*)&iUpdate);
hr=iUpdate->createupdatesarcher(&search);
wcout解决方案是在标准中添加“IsAssigned=1”。解决方案是在标准中添加“IsAssigned=1”