regedit注册表

using Microsoft.Win32;

StartMenu、控制面板删除安装信息

// HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall
var subKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
var ndpKey = Registry.LocalMachine.OpenSubKey(subKey);
if (ndpKey != null)
{
    var rslt = ndpKey.OpenSubKey(oldProductCode, true);
    if (rslt != null)
    {
        foreach (var item in rslt.GetValueNames())
        {
            rslt.DeleteValue(item, true);
        }
        rslt.Close();
    }
}                    
// HKEY_CLASSES_ROOT/Installer/Products
subKey = @"Installer\Products";
ndpKey = Registry.ClassesRoot.OpenSubKey(subKey);
if (ndpKey != null)
{
    var rslt = ndpKey.OpenSubKey(oldProductCode);
    if (rslt != null)
    {
        foreach (var item in rslt.GetValueNames())
        {
            rslt.DeleteValue(item, true);
        }
        rslt.Close();
    }
}                
// HKEY_CURRENT_USER/Software/Microsoft/Installer/Products
subKey = @"Software\Microsoft\Installer\Products";
ndpKey = Registry.CurrentUser.OpenSubKey(subKey);
if (ndpKey != null)
{
    var rslt = ndpKey.OpenSubKey(oldProductCode);
    if (rslt != null)
    {
        foreach (var item in rslt.GetValueNames())
        {
            rslt.DeleteValue(item, true);
        }
        rslt.Close();
    }
}  
posted @ 2020-12-19 11:16  wesson2019  阅读(247)  评论(0编辑  收藏  举报