public static void DeleteKey(string item) { //WriteToFile("Delete" + item); if (!string.IsNullOrEmpty(item)) { string currentUserSID = ReadRegistry.GetLoggedOnUserSID(); string subkeyPath = currentUserSID + "" + ""; string subkeyPathListApp = currentUserSID + "" + ""; RegistryKey key = Registry.Users.CreateSubKey(subkeyPath, true); RegistryKey keyListApp = Registry.Users.CreateSubKey(subkeyPathListApp, true); //Delete key in ListAppInstalled foreach (var subkey in key.GetSubKeyNames()) { if (subkey.Equals(item)) { key.DeleteSubKeyTree(subkey); } } //Delete key in ListApp foreach (var subkey in keyListApp.GetSubKeyNames()) { if (subkey.Equals(item)) { keyListApp.DeleteSubKeyTree(subkey); } } } }
public static void AddKey(string item) { //WriteToFile("Add key"); string currentUserSID = ReadRegistry.GetLoggedOnUserSID(); string appkeyPath = currentUserSID + ""; RegistryKey appkey = Registry.Users.OpenSubKey(appkeyPath); if (appkey != null) { string subkeyPath = currentUserSID + "" + ""; if (string.IsNullOrEmpty(item)) { RegistryKey key = Registry.Users.CreateSubKey(subkeyPath, true); } if (!string.IsNullOrEmpty(item)) { Registry.Users.CreateSubKey(currentUserSID + "" + "" + @"\" + item, true); } appkey.Close(); } }
public static List <string> GetListApplicationInRegistryInstall() { List <string> lApp = new List <string>(); string currentUserSID = ReadRegistry.GetLoggedOnUserSID(); string appkeyPath = currentUserSID + ""; RegistryKey appkey = Registry.Users.OpenSubKey(appkeyPath); { if (appkey != null) { string subkeyPath = currentUserSID + ""; RegistryKey key = Registry.Users.CreateSubKey(subkeyPath, true); string[] appBackup = key.GetSubKeyNames(); foreach (var itemApp in appBackup) { lApp.Add(itemApp); } key.Close(); appkey.Close(); return(lApp); } } return(null); }