首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何检查系统中是否安装了特定的修补程序(windows update)?

如何检查系统中是否安装了特定的修补程序(windows update)?
EN

Stack Overflow用户
提问于 2011-05-12 08:42:17
回答 1查看 3K关注 0票数 5

我有一些问题的Riched20.dll文件,这是由我的应用程序使用,这个问题是固定的应用KB884047热修复程序,为了避免问题与旧的windows版本,我想要检测这个热修复程序是什么时候应用在系统中,那么我如何才能检查一个特定的热修复程序(windows更新)是否安装在我的系统中使用Delphi语言?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-05-12 08:46:36

不久前,我写了一篇关于这个话题的博客search for installed windows updates using Delphi, WMI and WUA

关键是使用Windows Update Agent API

检查此示例代码。

代码语言:javascript
复制
//use in this way ISHotFixID_Installed('KB982799')
function  ISHotFixID_Installed(const HotFixID : string): Boolean;
var
  updateSession      : OleVariant;
  updateSearcher     : OleVariant;
  updateEntry        : OleVariant;
  updateSearchResult : OleVariant;
  UpdateCollection   : OleVariant;
  oEnum              : IEnumvariant;
  iValue             : LongWord;
begin
 result:=False;
  updateSession:= CreateOleObject('Microsoft.Update.Session');
  updateSearcher    := updateSession.CreateUpdateSearcher;
  //this line improves the performance , the online porperty indicates whether the UpdateSearcher goes online to search for updates. so how we are looking for already installed updates we can set this value to false
  updateSearcher.online:=False;
  updateSearchResult:= updateSearcher.Search(Format('IsInstalled = 1 and Type=%s',[QuotedStr('Software')]));
  UpdateCollection  := updateSearchResult.Updates;
  oEnum         := IUnknown(UpdateCollection._NewEnum) as IEnumVariant;
  while oEnum.Next(1, updateEntry, iValue) = 0 do
  begin
    Result:=Pos(HotFixID,updateEntry.Title)>0;
    updateEntry:=Unassigned;
    if Result then break;
  end;

end;
票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5972149

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档