开发者

List of Installed Updates on Windows 7 C#

With Microsoft Ultimate Wisdom they have changed the location of updates from Registry. I can get the updates from W开发者_如何学JAVAindows 2003 Servers no problem. Its just that Windows 7 is no longer in:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

Any body got any other ways to get it. Preferably in C# or using WMI?

God Save Microsoft with their Wisdom


For Window 7 64-bit it's in HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Updates


private string GetX64Installedsoftware()
{
    string Software = null;
    string SoftwareKey = @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall";

    Software += "\r\nWINDOWS X64 Software\r\n\r\n\r\n ";
    using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(SoftwareKey))
    {
        if (rk == null)
        {
            return Software;
        }
        foreach (string skName in rk.GetSubKeyNames())
        {
            using (RegistryKey sk = rk.OpenSubKey(skName))
            {
                try
                {
                    if (!(sk.GetValue("DisplayName") == null))
                    {
                        if (sk.GetValue("InstallLocation") == null)
                            Software += sk.GetValue("DisplayName") + " - Install path not known \r\n ";
                        else
                            Software += sk.GetValue("DisplayName") + " - " + sk.GetValue("InstallLocation") + "\r\n ";
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
    }
    return Software;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜