public void Init() { AppLog.Line(Program.fmt("Windows Update Manager, Version v{0} by David Xanatos", mVersion)); AppLog.Line(Program.fmt("This Tool is Open Source under the GNU General Public License, Version 3\r\n")); mUpdateSession = new UpdateSession(); mUpdateSession.ClientApplicationID = "Windows Update Manager"; mUpdateServiceManager = new UpdateServiceManager(); foreach (IUpdateService service in mUpdateServiceManager.Services) { if (service.Name == "Offline Sync Service") { mUpdateServiceManager.RemoveService(service.ServiceID); } else { mServiceList.Add(service.Name); } } mUpdateSearcher = mUpdateSession.CreateUpdateSearcher(); int count = mUpdateSearcher.GetTotalHistoryCount(); mUpdateHistory = mUpdateSearcher.QueryHistory(0, count); WindowsUpdateAgentInfo info = new WindowsUpdateAgentInfo(); var currentVersion = info.GetInfo("ApiMajorVersion").ToString().Trim() + "." + info.GetInfo("ApiMinorVersion").ToString().Trim() + " (" + info.GetInfo("ProductVersionString").ToString().Trim() + ")"; AppLog.Line(Program.fmt("Windows Update Agent Version: {0}", currentVersion)); }
public void CancelOperations() { if (mWebClient != null) { mWebClient.CancelAsync(); mWebClient = null; } if (mCallback == null) { return; } if (mSearchJob != null) { try { mUpdateSearcher.EndSearch(mSearchJob); } catch (Exception err) { } mSearchJob = null; } if (mOfflineService != null) { try { mUpdateServiceManager.RemoveService(mOfflineService.ServiceID); } catch (Exception err) { } mOfflineService = null; } if (mDownloadJob != null) { try { mDownloader.EndDownload(mDownloadJob); } catch (Exception err) { } mDownloadJob = null; } if (mInstalationJob != null) { try { if (mCallback.Install) { mInstaller.EndInstall(mInstalationJob); } else { mInstaller.EndUninstall(mInstalationJob); } } catch (Exception err) { } mInstalationJob = null; } mCallback = null; }