dburner

hackathon

Oct 28th, 2012
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.62 KB | None | 0 0
  1. private void SearchForPrograms(RegistryKey currentKey)
  2.         {
  3.             object displayName    = currentKey.GetValue("DisplayName");
  4.             object uninstalString = currentKey.GetValue("UninstallString");
  5.             object installString  = currentKey.GetValue("InstallLocation");
  6.  
  7.             if (displayName != null && uninstalString != null && installString != null)
  8.                 if (displayName as string != "" && uninstalString as string != "" && installString as string != "")
  9.                 AddToArray(displayName, installString, uninstalString);
  10.  
  11.             string[] subKeysArray = currentKey.GetSubKeyNames();
  12.             foreach (string subKey in subKeysArray)
  13.             {
  14.                 try
  15.                 {
  16.                     RegistryKey newKey = currentKey.OpenSubKey(subKey);
  17.                     if (newKey != null)
  18.                         SearchForPrograms(currentKey.OpenSubKey(subKey));
  19.                 }
  20.                 catch (System.Security.SecurityException e)
  21.                 {
  22.                 }
  23.             }
  24.         }
  25.  
  26.         HashSet<string> programsList = new HashSet<string>();
  27.         HashSet<string> installList = new HashSet<string>();
  28.         HashSet<string> uninstallList = new HashSet<string>();
  29.  
  30.         Hashtable programTable = new Hashtable();
  31.         private void AddToArray(object program, object install, object uninstall)
  32.         {
  33.             programsList.Add(program as string);
  34.             installList.Add(install as string);
  35.             uninstallList.Add(uninstall as string);
  36.  
  37.             programTable.Add(program as string, install as string);
  38.         }
Add Comment
Please, Sign In to add comment