Search code examples
vb.netregistrygetvaluedword

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


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


Solution

  • 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