Winify – Diff between revs 1 and 14
?pathlinks?
Rev 1 | Rev 14 | |||
---|---|---|---|---|
Line 162... | Line 162... | |||
162 | } |
162 | } |
|
163 | } |
163 | } |
|
164 | } |
164 | } |
|
165 | } |
165 | } |
|
Line -... | Line 166... | |||
- | 166 | |
||
- | 167 | /// <summary> |
||
- | 168 | /// Returns the machine GUID. |
||
- | 169 | /// </summary> |
||
- | 170 | /// <returns>the GUID of the machine</returns> |
||
- | 171 | /// <remarks>https://stackoverflow.com/questions/2333149/how-to-fast-get-hardware-id-in-c</remarks> |
||
- | 172 | public static string GetMachineGuid() |
||
- | 173 | { |
||
- | 174 | var location = @"SOFTWARE\Microsoft\Cryptography"; |
||
- | 175 | var name = "MachineGuid"; |
||
- | 176 | |
||
- | 177 | using (var localMachineX64View = |
||
- | 178 | RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)) |
||
- | 179 | { |
||
- | 180 | using (var rk = localMachineX64View.OpenSubKey(location)) |
||
- | 181 | { |
||
- | 182 | if (rk == null) |
||
- | 183 | { |
||
- | 184 | throw new KeyNotFoundException( |
||
- | 185 | string.Format("Key Not Found: {0}", location)); |
||
- | 186 | } |
||
- | 187 | |
||
- | 188 | var machineGuid = rk.GetValue(name); |
||
- | 189 | if (machineGuid == null) |
||
- | 190 | { |
||
- | 191 | throw new IndexOutOfRangeException( |
||
- | 192 | string.Format("Index Not Found: {0}", name)); |
||
- | 193 | } |
||
- | 194 | |
||
- | 195 | return machineGuid.ToString(); |
||
- | 196 | } |
||
- | 197 | } |
||
- | 198 | } |
||
166 | |
199 | |
|
167 | #endregion |
200 | #endregion |
|
168 | } |
201 | } |
|
169 | } |
202 | } |