Windows Update

来源:互联网 发布:北交大知行 编辑:程序博客网 时间:2024/06/05 14:35

6down voteaccepted
 

Add a Reference to WUApiLib to your C# project.

using WUApiLib;protected override void OnLoad(EventArgs e){    base.OnLoad(e);    UpdateSession uSession = new UpdateSession();    IUpdateSearcher uSearcher = uSession.CreateUpdateSearcher();    uSearcher.Online = false;    try {        ISearchResult sResult = uSearcher.Search("IsInstalled=1 And IsHidden=0");        textBox1.Text = "Found " + sResult.Updates.Count + " updates" + Environment.NewLine;        foreach (IUpdate update in sResult.Updates) {                textBox1.AppendText(update.Title + Environment.NewLine);        }    }    catch (Exception ex) {        Console.WriteLine("Something went wrong: " + ex.Message);    }}


 

 

Given you have a form with a TextBox this will give you a list of the currently installed updates. Seehttp://msdn.microsoft.com/en-us/library/aa387102(VS.85).aspx for more documentation.

This will, however, not allow you to find KB hotfixes which are not distributed via Windows Update.

0 0
原创粉丝点击