2011-05-12 15 views
5

Tengo algunos problemas con el archivo Riched20.dll que utiliza mi aplicación, este problema se soluciona aplicando la revisión KB884047, para evitar problemas con las versiones anteriores de Windows, quiero detectar cuándo se aplica esta revisión en el sistema Entonces, ¿cómo puedo verificar si un hotfix particular (actualización de Windows) está instalado en mi sistema usando Delphi?¿Cómo puedo verificar si un hotfix particular (actualización de Windows) está instalado en mi sistema?

Respuesta

9

Hace algún tiempo, escribió en su blog acerca de este tema search for installed windows updates using Delphi, WMI and WUA

La clave es usar el cheque Windows Update Agent API

este código de ejemplo.

//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; 
Cuestiones relacionadas