Using the Idea from the code on the page here
http://msdn.microsoft.com/en-us/library/microsoft.win32.registryvaluekind(v=VS.90).aspx[
^]
I was able to create another test project. 1 textbox and 5 buttons.
By Working with the Format I could change the way the output looked, by adding spaces or the comma to "{0:X2}," .I still had to use the Stringbuilder Because I don't know of another way to get the array into a textbox without building the string.
The result returned is the same that shows up in Regedit.
See the code below, the output is commented in the button click event it was created in.
Thanks again for pushing me in the right direction.
Note: Watch out for line wrapping in the posted code.
Imports System
Imports Microsoft.Win32
Imports System.Text
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strbldr As New Stringbuilder
Dim regbinary() As Byte
regbinary = (Registry.CurrentUser.OpenSubKey("Software\Licenses").GetValue("{R7C0DB872A3F777C0}"))
For Each strbyte In regbinary
strbldr.AppendFormat("{0:X2} ", strbyte)
Next 'returns 2F 59 41 42
TextBox1.Text = strbldr.ToString
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim strbldr As New StringBuilder
Dim regbinary() As Byte
regbinary = (Registry.CurrentUser.OpenSubKey("Software\Licenses").GetValue("{R7C0DB872A3F777C0}"))
For Each strbyte In regbinary
strbldr.AppendFormat("{0:X2}", strbyte)
Next 'Returns 2F594142
TextBox1.Text = strbldr.ToString
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim strbldr As New StringBuilder
Dim regbinary() As Byte
regbinary = (Registry.CurrentUser.OpenSubKey("Software\Licenses").GetValue("{R7C0DB872A3F777C0}"))
For Each strbyte In regbinary
strbldr.AppendFormat("{0:X2} ", strbyte & ",")
Next 'Returns 47, 89, 65, 66,
TextBox1.Text = strbldr.ToString
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim strbldr As New StringBuilder
Dim regbinary() As Byte
regbinary = (Registry.CurrentUser.OpenSubKey("Software\Licenses").GetValue("{R7C0DB872A3F777C0}"))
For Each strbyte In regbinary
strbldr.AppendFormat("{0:X2},", strbyte)
Next 'Returns 2F,59,41,42,
TextBox1.Text = strbldr.ToString
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim strbldr As New StringBuilder
Dim regbinary() As Byte
regbinary = (Registry.CurrentUser.OpenSubKey("Software\Licenses").GetValue("{R7C0DB872A3F777C0}"))
For i As Integer = 0 To regbinary.Length - 1
' Display each byte as two hexadecimal digits.
strbldr.AppendFormat("{0:X2}", regbinary(i))
Next 'Returns 2F594142
TextBox1.Text = strbldr.ToString
End Sub
End Class