Creating Zero-Length Binary in Registry
I'm trying to create a new binary value under the HKCU\Software\Microsoft\Internet Explorer\New Windows\Allow key. Unfortunately I am having some trouble. How do I create a new zero-length binary key?
I'm using this function which uses the RegCreateKeyEx in the AdvAPI32 API.
VB Code:
Public Function CreateNewKey(sNewKeyName As String, lPredefinedKey As Long)
Dim hNewKey As Long 'handle to the new key
Dim lRetVal As Long 'result of the RegCreateKeyEx function
lRetVal = RegCreateKeyEx(lPredefinedKey, sNewKeyName, 0&, _
vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, _
0&, hNewKey, lRetVal)
RegCloseKey (hNewKey)
End Function
And this is the code to use the function:
VB Code:
For i = 1 To 3
strValue = RegGetValue$(HKEY_CURRENT_USER, strSubKey, arrSites(i))
If strValue = "" Then
frmMain.CreateNewKey strSubKey, HKEY_CURRENT_USER
frmMain.SetKeyValue strSubKey, arrSites(i), "", 3
Else
End If
Next
Does this look like I'm doing it right?
Re: Creating Zero-Length Binary in Registry
Just realized why this might not be working. In my code I'm trying to create a key that already exists, what I need to do is create multiple values.
So I would need to change it to check for the key if it does exist then just create values. If it doesn't exist create the key then create the values.
Right?
*EDIT*
Although I'm still unsure if that is the correct way to make a zero-length binary value. I know a zero-length string is "" but what is the binary equivalent?