5
我的應用程序使用的Riched20.dll文件存在一些問題,此問題已修復應用KB884047修補程序,爲了避免舊windows版本出現問題,我希望檢測系統中應用此修補程序的時間,所以如何我可以檢查一個特定的修補程序(Windows更新)是否安裝在我的系統使用delphi?如何檢查我的系統中是否安裝了特定的修補程序(Windows更新)?
我的應用程序使用的Riched20.dll文件存在一些問題,此問題已修復應用KB884047修補程序,爲了避免舊windows版本出現問題,我希望檢測系統中應用此修補程序的時間,所以如何我可以檢查一個特定的修補程序(Windows更新)是否安裝在我的系統使用delphi?如何檢查我的系統中是否安裝了特定的修補程序(Windows更新)?
前一段時間,我在博客這個話題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;