从 VB.NET 中的注册表中获取实际 REG_DWORD 十进制数的另一条途径?

Another route to get actual REG_DWORD decimal number from registry in VB.NET?

我一直在将 GetValue 与 GetValueKind 结合使用,并且刚刚在读取大于带符号的 32 位整数的 DWORD 时遇到问题。我能够不受限制地写入注册表,达到最大值 4294967295(十六进制的 ffffffff)。

如果有办法用 int64 做到这一点,那么我就不会受到限制..

如果我可以读取十六进制值,我就可以完成这项工作,我可以通过 int64 将其转换为十进制值,不过我还是不知道如何从注册表中读取十六进制值..

当它超过带符号的 32 位整数值 2,147,483,647 时,我是否应该采取其他方法让我读取正确的值?

谢谢

DWORD 是 32 位无符号整数 - 不是有符号整数,因此请改用 UInt32

根据2.2.9 DWORD

A DWORD is a 32-bit unsigned integer (range: 0 through 4294967295 decimal). Because a DWORD is unsigned, its first bit (Most Significant Bit (MSB)) is not reserved for signing.

Data Type Summary (Visual Basic)

资源:

Dim PATH as string = "HKEY_CURRENT_USER\Software\Test"
Dim NAME as string = "TestName"
Dim ft As String = "DOES_NOT_EXIST"
Dim gv As Object = Registry.GetValue(PATH, NAME, ft)
Dim gb As Byte() = BitConverter.GetBytes(CInt(gv))
Dim j As UInt32 = BitConverter.ToUInt32(gb, 0)
Textbox1.text = j