private static bool CheckWindowsUpdate(string kb) { try { UpdateSession session1 = (UpdateSession)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("4CB43D7F-7EEE-4906-8698-60DA1C38F2FE"))); IUpdateSearcher searcher = session1.CreateUpdateSearcher(); searcher.Online = false; IUpdateHistoryEntryCollection entrys = session1.QueryHistory(string.Empty, 0, searcher.GetTotalHistoryCount()); for (int i = 0; i < entrys.Count; i++) { IUpdateHistoryEntry entry = entrys[i]; if (((entry != null) && (entry.Title != null)) && entry.Title.Contains(kb)) { return(true); } } return(false); } catch (Exception) { return(true); } }
public Update(IUpdateHistoryEntry update) { Title = update.Title; Description = update.Description; Date = update.Date.ToString(); }
/// <summary> /// checks whether an entry of the update history is a successful /// uninstallation operation /// </summary> /// <param name="uhe">an update history entry</param> /// <returns>Returns true, if the entry marks a successful uninstallation.</returns> private static bool isUninstallSuccess(IUpdateHistoryEntry uhe) { if (uhe == null) return false; if (uhe.Operation == UpdateOperation.uoUninstallation) { return (uhe.ResultCode == OperationResultCode.orcSucceeded || uhe.ResultCode == OperationResultCode.orcSucceededWithErrors); } return false; }