我如何检查我的系统中是否安装了特定的修补程序(Windows更新)?

Sal*_*dor 5 delphi hotfix

我有一些问题与我的应用程序使用的Riched20.dll文件,这个问题是修复应用KB884047修补程序,以避免旧的Windows版本的问题,我想检测何时在系统中应用此修补程序,所以如何使用delphi检查我的系统中是否安装了特定的修补程序(Windows更新)?

RRU*_*RUZ 9

前段时间,我在博客上谈到了这个话题 search for installed windows updates using Delphi, WMI and WUA

关键是使用Windows Update Agent API

检查此示例代码.

//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;
Run Code Online (Sandbox Code Playgroud)