人人人人人人人人人人人人

c# 通过注册表判断有没有安装某个软件

 

        private bool checkHasInstalledSoftWare(string displayName)
        {
            Microsoft.Win32.RegistryKey uninstallNode = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall");
            foreach (string subKeyName in uninstallNode.GetSubKeyNames())
            {
                Microsoft.Win32.RegistryKey subKey = uninstallNode.OpenSubKey(subKeyName);
                object disName = subKey.GetValue("DisplayName");
                if (disName != null)
                {
                    if (disName.ToString()== displayName)
                    {
                         return true;
                        // MessageBox.Show(displayName.ToString());  
                         Debug.Print(""+displayName);//Microsoft Edge

                    }
                }
            }
            return false;
        }

  调用:

 

if (checkHasInstalledSoftWare("Microsoft Edge"))
{
//.......
}
else {
//-----------
}


posted @ 2021-02-09 17:32  wgscd  阅读(45)  评论(0编辑  收藏  举报
test red font.