1 namespace Beisen.Native 2 { 3 using Beisen.Pdf; 4 using System; 5 using System.Runtime.InteropServices; 6 7 internal sealed class DeviceInfo 8 { 9 private static DeviceInfo _Instance; 10 11 public static DeviceInfo Instance 12 { 13 get 14 { 15 if (_Instance == null) 16 { 17 _Instance = new DeviceInfo(); 18 } 19 return _Instance; 20 } 21 } 22 23 public string Id 24 { 25 get 26 { 27 uint volumeSerialNumber = 0; 28 uint num = 0u; 29 uint num2 = 0; 30 uint num3 = 0; 31 uint num4 = 0; 32 uint num5 = 0; 33 string systemDirectory = Environment.SystemDirectory; 34 if ((systemDirectory != null) && (systemDirectory.Length > 0)) 35 { 36 uint num6; 37 FileSystemFeature fileSystemFeature; 38 Platform.GetVolumeInformation(string.Format("{0}:\\", systemDirectory[0]), null, 0, out num, out num6, out fileSystemFeature, null, 0); 39 } 40 string g = RegistryWOW6432.GetRegKey32<string>(RegHive.HKEY_LOCAL_MACHINE, @"SOFTWARE\Microsoft\Cryptography", "MachineGuid"); 41 if ((g == null) || (g.Trim() == "")) 42 { 43 g = RegistryWOW6432.GetRegKey64<string>(RegHive.HKEY_LOCAL_MACHINE, @"SOFTWARE\Microsoft\Cryptography", "MachineGuid"); 44 } 45 if (g != null) 46 { 47 byte[] buffer = new Guid(g).ToByteArray(); 48 if (buffer != null) 49 { 50 num2 = BitConverter.ToUInt32(buffer, 0); 51 num3 = BitConverter.ToUInt32(buffer, 4); 52 num4 = BitConverter.ToUInt32(buffer, 8); 53 num5 = BitConverter.ToUInt32(buffer, 12); 54 } 55 } 56 return $"{volumeSerialNumber}-{num2}-{num3}-{num4}-{num5}"; 57 } 58 } 59 } 60 }