|
|
1.1 ! root 1: using System.Collections.Generic; ! 2: using System.Diagnostics; ! 3: using System.IO; ! 4: using System.Text; ! 5: ! 6: namespace CleanFlashCommon { ! 7: public class RegistryManager { ! 8: ! 9: public static void ApplyRegistry(string registryContents) { ! 10: registryContents = "Windows Registry Editor Version 5.00\n\n" + SystemInfo.FillString(registryContents); ! 11: string filename = Path.GetTempFileName(); ! 12: ! 13: File.WriteAllText(filename, registryContents, Encoding.Unicode); ! 14: ! 15: Directory.SetCurrentDirectory(Path.GetDirectoryName(filename)); ! 16: ! 17: ExitedProcess process = ProcessRunner.RunProcess( ! 18: new ProcessStartInfo { ! 19: FileName = "reg.exe", ! 20: Arguments = "import " + Path.GetFileName(filename), ! 21: UseShellExecute = false, ! 22: CreateNoWindow = true ! 23: } ! 24: ); ! 25: ! 26: File.Delete(filename); ! 27: ! 28: if (!process.IsSuccessful) { ! 29: throw new InstallException(string.Format("Failed to apply changes to registry: error code {0}\n\n{1}", process.ExitCode, process.Output)); ! 30: } ! 31: } ! 32: ! 33: public static void ApplyRegistry(List<string> registryContents) { ! 34: ApplyRegistry(string.Join("\n\n", registryContents)); ! 35: } ! 36: ! 37: public static void ApplyRegistry(params string[] registryContents) { ! 38: ApplyRegistry(string.Join("\n\n", registryContents)); ! 39: } ! 40: } ! 41: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.