Windows Update Agent pure win32 APIs
Windows Update Agent pure win32 APIs
我正在开发一个示例代码,以获取有关Windows更新监视的信息。我碰到Windows Update Agent API。链接:http://msdn.microsoft.com/en-us/library/windows/desktop/aa387099(v = vs.85).aspx
,但我找不到Win32的任何API。我只找到C#/。网络接口。是否有相应的Win32 API?
特别是我想找出Windows Update/Patch的"发布日期"。期待任何建议和指导。
- srivathsa
WUA API包含一组COM接口,可以从C 应用中使用,因此请尝试这些IUpdateSearcher
,IUpdateSession
和IUpdate
。
检查此示例C 应用程序,该应用程序检索更新和发布日期。
#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=1 or IsHidden=1 or IsPresent=1");
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);
switch(hr)
{
case S_OK:
wcout<<L"List of applicable items on the machine:"<<endl;
break;
case WU_E_LEGACYSERVER:
wcout<<L"No server selection enabled"<<endl;
return 0;
case WU_E_INVALID_CRITERIA:
wcout<<L"Invalid search criteria"<<endl;
return 0;
}
IUpdateCollection *updateList;
IUpdate *updateItem;
LONG updateSize;
BSTR updateName;
DATE retdate;
results->get_Updates(&updateList);
updateList->get_Count(&updateSize);
if (updateSize == 0)
{
wcout << L"No updates found"<<endl;
}
for (LONG i = 0; i < updateSize; i++)
{
updateList->get_Item(i,&updateItem);
updateItem->get_Title(&updateName);
updateItem->get_LastDeploymentChangeTime(&retdate);
COleDateTime odt;
odt.m_dt=retdate;
wcout<<i+1<<" - "<<updateName<<" Release Date "<< (LPCTSTR)odt.Format(_T("%A, %B %d, %Y"))<<endl;
}
::CoUninitialize();
wcin.get();
return 0;
}
相关文章:
- Win32编译器选项和内存分配
- C++win32 API创建多个类似视口的窗口
- WM_CTLCOLORSTATIC从未在WIN32应用程序中触发
- 检测win32服务创建和删除的最佳方法
- WIN32:C++,为什么在WM_CLOSE上调用Messagebox函数程序正在冻结
- 将 win32 hbitmap 转换为 winrt softwarebitmap
- 使用 WIN32 API (C/C++) 对特定树视图项进行着色
- Alt+Enter 在 Win32 应用中,管理大小调整和分辨率
- VSCode C++ 编译的exe感染了Win32:TrojanX-gen[Trj]
- 从预处理器获取 Windows 版本(C++ Win32)
- Issues with Win32 ReadProcessMemory API
- Win32 发送输入鼠标移动滞后并冻结
- 如何从 Win32 C++ 应用程序输出到父控制台窗口?
- C++线程:如何在一个线程仍在运行时阻止另一个线程执行 (Win32)
- 将 Win32/WinAPI 应用程序移植到 wxWidgets
- Win32 API 控制台光标在 WriteConsole 后不移动
- C++ Win32 Threads
- C++ win32 如何使密码字段可选并启用复制和粘贴?
- LNK1104:无法打开libpjproject-i386-Win32-vc14-Debug-Static.lib
- Windows Update Agent pure win32 APIs