更新时间:2023-02-07 20:37:31
添加引用WUApiLib到C#项目。
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);
}
}
鉴于你有一个文本框的表单这会给你当前已安装的更新列表。见http://msdn.microsoft.com/en-us/library/aa387102(VS.85).aspx更多的文档。
这将,但是,不会让你查找不通过Windows Update分发KB修补程序。
This will, however, not allow you to find KB hotfixes which are not distributed via Windows Update.