Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Windows Update Agent Update-Titel (https://www.delphipraxis.net/181180-windows-update-agent-update-titel.html)

Smaraner 22. Jul 2014 16:40

Windows Update Agent Update-Titel
 
Hallo,

ich habe mir mal Windows Update Agent angesehen (http://theroadtodelphi.wordpress.com...i-wmi-and-wua/) und wollte das jetzt für ein Programm nutzen. Ich stehe aber ein bisschen auf dem Schlauch. Der Code zur Updatesuche:

Delphi-Quellcode:
procedure GetListNotInstalledUpdates;
var
  updateSession       : OleVariant;
  updateSearcher      : OleVariant;
  updateSearchResult  : OleVariant;
  updateEntry         : OleVariant;
  UpdateCollection    : OleVariant;
  oEnum               : IEnumvariant;
  iValue              : LongWord;
begin
  updateSession:= CreateOleObject('Microsoft.Update.Session');
  updateSearcher := updateSession.CreateUpdateSearcher;
  Writeln('Searching');
  updateSearchResult:= updateSearcher.Search(Format('IsInstalled = 0 and Type=%s',[QuotedStr('Software')]));
  UpdateCollection := updateSearchResult.Updates;
  oEnum        := IUnknown(UpdateCollection._NewEnum) as IEnumVariant;
  while oEnum.Next(1, updateEntry, iValue) = 0 do
  begin
    Writeln(updateEntry.Title);
    updateEntry:=Unassigned;
  end;
  Writeln('Done');
end;
Der Code zur Installation:

Delphi-Quellcode:
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;
Ich dachte mir, dass ich in der While Schleife der Procedur zur Update-Suche einfach die Funktion zur Update-Installation aufrufe:

Delphi-Quellcode:
ISHotFixID_Installed(updateEntry.Title);
Nur enthält updateEntry.Title den Titel und nicht die richtige Bezeichnung und somit werden die Updates nicht installiert.

Smaraner 23. Jul 2014 18:47

AW: Windows Update Agent Update-Titel
 
Ich benötige die Hot Fix ID. Diese wird beim Update-Namen in Klammern angegeben. Ich würde diese sonst aus dem Namen extrahieren, aber es gibt sicher eine einfachere Lösung. :wink:


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:56 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz