Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #UDT
- #UltimateDevTeam
- public static string GetMachineGuid()
- {
- string location = @"SOFTWARE\Microsoft\Cryptography";
- string name = "MachineGuid";
- using (RegistryKey localMachineX64View = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64))
- {
- using (RegistryKey rk = localMachineX64View.OpenSubKey(location))
- {
- if (rk == null)
- throw new KeyNotFoundException(string.Format("Key Not Found: {0}", location));
- object machineGuid = rk.GetValue(name);
- if (machineGuid == null)
- throw new IndexOutOfRangeException(string.Format("Index Not Found: {0}", name));
- return machineGuid.ToString();
- }
- }
- }
- #UDT
- #UltimateDevTeam
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement