因为可能是32位或者64位,所以两层都写,按需要使用
Dim keyBaseX64 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)
Dim keyX64 = keyBaseX64.OpenSubKey("SOFTWARE\Microsoft\Cryptography", RegistryKeyPermissionCheck.ReadSubTree)
Dim resultObjX64 As String = keyX64.GetValue("MachineGuid", "").ToString
keyX64.Close()
keyBaseX64.Close()
keyX64.Dispose()
keyBaseX64.Dispose()
Dim keyBaseX86 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)
Dim keyX86 = keyBaseX86.OpenSubKey("SOFTWARE\Microsoft\Cryptography", RegistryKeyPermissionCheck.ReadSubTree)
Dim resultObjX86 As String = keyX86.GetValue("MachineGuid", "").ToString
keyX86.Close()
keyBaseX86.Close()
keyX86.Dispose()
keyBaseX86.Dispose()
If resultObjX64 <> "" Then
strRegValue = resultObjX64
Else
strRegValue = resultObjX86
End If