如何查询使用C#安装在计算机上的Windows更新的准确和本地化列表? [英] How can I query for an accurate and localized list of Windows updates installed on a machine using C#?

查看:61
本文介绍了如何查询使用C#安装在计算机上的Windows更新的准确和本地化列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将准确定义为与"Microsoft Windows"中显示的内容相匹配Windows 7的程序和功能"下的查看安装的更新"对话框中的类别".

I define accurate as matching what is displayed in the "Microsoft Windows" category of Microsoft's View Installed Updates dialog under Programs and Features in Windows 7.

如果我使用WUApi.DLL,则信息将本地化返回,但我无法获得准确的列表.对于WUApi.dll,缺少某些修补程序,并且如果卸载了更新,它仍会显示在以下代码生成的列表中:

If I use WUApi.DLL, the information is returned localized but I can't get an accurate list. In the case of WUApi.dll, some hotfixes are missing and if an update has been uninstalled, it still shows up in the list generated by the following code:

public static void GetWindowsUpdates() 
{ 
    var updateSession = new UpdateSession(); 
    var updateSearcher = updateSession.CreateUpdateSearcher(); 
    var count = updateSearcher.GetTotalHistoryCount(); 
    if (count == 0) 
        return; 

    var history = updateSearcher.QueryHistory(0, count); 
    for (int i = 0; i < count; i++) 
    { 
        if (history[i].ResultCode == OperationResultCode.orcSucceeded) 
        { 
            Console.WriteLine(history[i].Title); 

            if (history[i].Operation == UpdateOperation.uoUninstallation) 
            { 
                Console.WriteLine("!!! Operation == uninstall"); // This is never true 
            } 
        } 
    } 
} 

WUApi搜索方法还没有使用以下代码提供准确的列表:

The WUApi search method also didn't provide an accurate list using the following code:

        WUApiLib.UpdateSessionClass session = new WUApiLib.UpdateSessionClass(); 
        WUApiLib.IUpdateSearcher searcher = session.CreateUpdateSearcher(); 

        searcher.IncludePotentiallySupersededUpdates = true; 

        WUApiLib.ISearchResult result = searcher.Search("IsInstalled=1"); 
        Console.WriteLine("Updates found: " + result.Updates.Count); 
        foreach (IUpdate item in result.Updates) 
        { 
            Console.WriteLine(item.Title); 
        } 

如果使用WMI读取更新列表,则可以获得准确的列表,但未本地化.我使用以下代码:

If I use WMI to read the list of updates, I can get an accurate list, but it is not localized. I use the following code:

ManagementObjectSearcher searcher = new ManagementObjectSearcher(new ObjectQuery("select * from Win32_QuickFixEngineering")); searcher.Options.UseAmendedQualifiers = true; searcher.Scope.Options.Locale = "MS_" + CultureInfo.CurrentCulture.LCID.ToString("X"); ManagementObjectCollection results = searcher.Get(); Console.WriteLine("\n==WMI==" + results.Count); foreach (ManagementObject item in results) { Console.WriteLine("\t--Properties--"); foreach (var x in item.Properties) { Console.WriteLine(x.Name + ": " + item[x.Name]); } Console.WriteLine("\t--System Properties--"); foreach (var x in item.SystemProperties) { Console.WriteLine(x.Name + ": " + x.Value); } Console.WriteLine("\t--Qualifiers--"); foreach (var x in item.Qualifiers) { Console.WriteLine(x.Name + ": " + x.Value); } }

P.S. Its an old thread from stackoverflow but no answer mentioned there.

推荐答案

Hi Sricharan Andugulapati,

Hi Sricharan Andugulapati,

谢谢您在这里发布.

Based on my search, have you check the file location?

Based on my search, have you check the file location?

If wuapi.dll is located in a subfolder of C:\Windows\System32, the security rating is 20% dangerous. The file size is 577,048 bytes. The wuapi.dll file is a Microsoft signed file. It can change the behavior of other programs or manipulate other programs. The program is not visible. The file is certified by a trustworthy company. The service has no detailed description. The file is not a Windows system file.

If wuapi.dll is located in a subfolder of C:\Windows\System32, the security rating is 20% dangerous. The file size is 577,048 bytes. The wuapi.dll file is a Microsoft signed file. It can change the behavior of other programs or manipulate other programs. The program is not visible. The file is certified by a trustworthy company. The service has no detailed description. The file is not a Windows system file.

If wuapi.dll is located in a subfolder of C:\Windows, the security rating is 40% dangerous. The file size is 560,128 bytes. It is a Microsoft signed file. It can change the behavior of other programs or manipulate other programs. The program is not visible. There is no detailed description of this service. It is not a Windows core file.

If wuapi.dll is located in a subfolder of C:\Windows, the security rating is 40% dangerous. The file size is 560,128 bytes. It is a Microsoft signed file. It can change the behavior of other programs or manipulate other programs. The program is not visible. There is no detailed description of this service. It is not a Windows core file.

I found a similar question for reference.

I found a similar question for reference.

我希望这会对您有所帮助.

I hope this would be helpful to you.

最好的问候,

温迪


这篇关于如何查询使用C#安装在计算机上的Windows更新的准确和本地化列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆