欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#實現(xiàn)讀取注冊表監(jiān)控當前操作系統(tǒng)已安裝軟件變化的方法

 更新時間:2015年08月21日 12:36:26   作者:我心依舊  
這篇文章主要介紹了C#實現(xiàn)讀取注冊表監(jiān)控當前操作系統(tǒng)已安裝軟件變化的方法,涉及C#針對注冊表的讀取與監(jiān)控技巧,非常具有實用價值,需要的朋友可以參考下

本文實例講述了C#實現(xiàn)讀取注冊表監(jiān)控當前操作系統(tǒng)已安裝軟件變化的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:

private static HybridDictionary GetSoftName()
{
 string strSoftName = string.Empty;
 HybridDictionary hdSoftName = new HybridDictionary();
 /*對注冊表節(jié)點"Software/Microsoft/Windows/CurrentVersion/Uninstall"下的內(nèi)容進行操作。
 RegistryKey Registry 為注冊表操作類*/
 using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall", false))
 {
  if (key != null)
  {
   foreach (string keyName in key.GetSubKeyNames())
   {
    using (RegistryKey key2 = key.OpenSubKey(keyName, false))
    {
     if (key2 != null)
     {
      string softwareName = Convert.ToString(key2.GetValue("DisplayName"));//獲取DisplayName,如存在值,則系統(tǒng)中安裝有該軟件
      //string installLocation = key2.GetValue("InstallLocation", "").ToString();//軟件安裝路徑
      if (!string.IsNullOrEmpty(softwareName))
      {
       if (!hdSoftName.Contains(softwareName))
       {
        hdSoftName.Add(softwareName, string.Empty);//將軟件名作為集合的key
       }
      }
     }
    }
   }
  }
 }
 return hdSoftName;
}

希望本文所述對大家的C#程序設計有所幫助。

相關文章

最新評論