RegistryManager.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Microsoft.Win32;
  6. namespace Aitex.Core.RT.Key
  7. {
  8. public class RegistryManager
  9. {
  10. /*
  11. *
  12. *
  13. *
  14. *
  15. *
  16. */
  17. public static string PathMachineCode = "Software\\MyTech\\MachineCode";
  18. public static string PathRegisterCode = "Software\\MyTech\\RegisterCode";
  19. public static string ValueRegisterCode = "Code";
  20. public static string Read(string path, string keyname)
  21. {
  22. RegistryKey registryKey = Registry.LocalMachine.CreateSubKey(path);
  23. if (registryKey == null)
  24. {
  25. return string.Empty;
  26. }
  27. object value = registryKey.GetValue(keyname);
  28. if (value != null)
  29. {
  30. return value.ToString();
  31. }
  32. return string.Empty;
  33. }
  34. public static void Write(string path, string keyname, string keyvalue)
  35. {
  36. RegistryKey registryKey = Registry.LocalMachine.CreateSubKey(path);
  37. if (registryKey == null)
  38. {
  39. return;
  40. }
  41. registryKey.SetValue(keyname, keyvalue);
  42. }
  43. }
  44. }