Reputation: 1
I have been using GetValue with GetValueKind and have just come across an issue when Reading DWORD that is larger than the signed 32-bit integer. I am able to Write to to the registry without restriction, getting to the max of 4294967295 (ffffffff in hex).
If there was a way to do this with int64 then I wouldnt be restricted..
I could make this work if I could read the hexadecimal value, which i could just convert to decimal via int64, though again, I dont know how i would read the hex value from the registry..
Is there another route I should take to allow me to Read the correct value when it exceeds the signed 32-bit integer value of 2,147,483,647?
thanks
Upvotes: 0
Views: 911
Reputation: 1
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
Upvotes: 0
Reputation: 5009
DWORD is a 32-bit unsigned integer - not a signed integer, so use UInt32
instead.
According to 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)
Resources:
Upvotes: 0