PDA

Click to See Complete Forum and Search --> : Need Serious Help - Converting a String Key to a Binary Key


woods91
Mar 6th, 2002, 08:36 PM
I need to convert a registry key in win 95 that has a string value to a new registry key that has a binary value. Then I need to pull the binary value out of the newly created key and view it as a string to make sure these values match the original values as set in the string key.

Can anyone please help?????

DerFarm
Mar 7th, 2002, 05:52 PM
can you give an example of the string key?

woods91
Mar 8th, 2002, 10:49 AM
Ok here are the specifics:

Windows 95 registry: under HKEY_CURRENT_USER\Software\Microsoft\Office\9.0\Outlook\Categories
Key: Master list
Value: String

I need to read these values from the registry - had success
Convert these string values to their binary/hex equivalent

Create a new key with a binary value

Insert the converted values into this new key as binary

Finally read these values from the new key (stored as binary)

and write to a message box the string equivalent. Check to make sure these values from the new key are the same as the original string values from the original key.

I hope this makes sense????

Thanks
Phil.

DerFarm
Mar 8th, 2002, 12:15 PM
The code for translating Decimal to Binary:


Function Bin2Dec(strBinary As String) As Long
Dim Ret_Val As Long, intBinLen As Integer
Dim i As Integer

intBinLen = Len(strBinary)
For i = intBinLen To 1 Step (-1)
If Mid$(strBinary, i, 1) = "1" Then
Ret_Val = Ret_Val + (2 ^ (intBinLen - i))
End If
Next i
Xit_Bin2Dec:
Bin2Dec = Ret_Val
End Function


Translating Decimal to Binary

Function Dec2Bin(lngDecimal As Long) As String
Dim Ret_Val As String, dbl_Temp0 As Double
Dim str_Temp0 As String

lng_Temp0 = lngDecimal
Ret_Val = ""
While lng_Temp0 > 0
str_Temp0 = "0"
lng_Temp0 = lng_Temp0 / 2

If lng_Temp0 > Int(lng_Temp0) Then str_Temp0 = "1"

Ret_Val = str_Temp0 & Ret_Val
lng_Temp0 = Int(lng_Temp0)
Wend


Xit_Dec2Bin:
Dec2Bin = Ret_Val
End Function