i have been trying to solve this for about an hr and its really stumped me, can u post ur process of converting to hex so i can have more to work with
Hi, this should work: Code: Public Function GetRD(ByVal Path As String, ByVal Value As String) As String Dim str As String = String.Empty Dim Format As String = String.Empty Dim Data As Object = Registry.GetValue(Path, Value, Nothing) If Data Is Nothing Then Return "N/A" For j As Integer = LBound(Data) To UBound(Data) str = str & Hex(Data(j)) Next str = BitConverter.ToString(Data).Replace("-", "") str = Regex.Replace(str, "(.{2})", "$0 ") For i As Integer = 0 To str.Length - 1 Step 1 If i > 0 And i Mod 24 = 0 Then Format &= Environment.NewLine End If Format &= str(i).ToString Next Return Format End Function Usage: Code: TextBox1.Text = GetRD("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion", "DigitalProductId")
Ok didn't really need the values, this new function has values removed.. Code: Public Function GetRD(ByVal Path As String, ByVal Value As String) As String Dim str As String = String.Empty Dim Format As String = String.Empty Dim Data As Object = Registry.GetValue(Path, Value, Nothing) If Data Is Nothing Then Return "N/A" For j As Integer = LBound(Data) To UBound(Data) str = str & Hex(Data(j)) Next str = BitConverter.ToString(Data).Replace("-", "") str = Regex.Replace(str, "(.{2})", "$0 ") For i As Integer = 0 To str.Length - 1 Step 1 If i > 0 And i Mod 24 = 0 Then Format &= Environment.NewLine End If Format &= str(i).ToString Next Return Format End Function
Not had time today to look at this, i do however have a vbscript to display it in messagebox (should be simple enough to convert). Code: Const HKLM = &H80000002 Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") sKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\" sValueName = "DigitalProductId" oReg.GetBinaryValue HKLM, sKeyPath, sValueName, sValue sContents = "" For i = 0 To UBound(sValue) vByte = sValue(i) If vByte <> 0 And vByte <> "" Then sContents = sContents & Chr(vByte) End If Next WScript.Echo sContents Ill have a look in a bit, have to go im real busy today..
lol i got the correct function here but only diplaying first char.. encoding should be utf7 or default, all others display incorrectly Ill aslo have a look at converting the vbscript. Ill try again when im soba..
Ok here is code : Code: Public Function PID() Dim Reg As Object = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion", False) Dim Data As Byte() Dim str As String = String.Empty Data = Reg.GetValue("DigitalProductId") Reg.Close() For j As Integer = 0 To UBound(Data) Dim byt As Byte = Data(j) If byt = 0 Then byt = &H2E End If str = str & Chr(byt) Next str = Regex.Replace(str, "(.{1})", "$0 ") Return str End Function Usage: Code: TextBox1.Text = PID()