Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/130.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 使用wuapi获取Windows系统更新_C++_Windows_Winapi_Windows Update - Fatal编程技术网

C++ 使用wuapi获取Windows系统更新

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,

在我的应用程序中,我显示windows计算机是否有可用的更新,这些更新应与“windows Update”设置相同。我使用的是这样的代码,它通常是有效的

#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”