Results 1 to 2 of 2

Thread: Creating Zero-Length Binary in Registry

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Location
    Chicago
    Posts
    136

    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:
    1. Public Function CreateNewKey(sNewKeyName As String, lPredefinedKey As Long)
    2.     Dim hNewKey As Long         'handle to the new key
    3.     Dim lRetVal As Long         'result of the RegCreateKeyEx function
    4.  
    5.     lRetVal = RegCreateKeyEx(lPredefinedKey, sNewKeyName, 0&, _
    6.               vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, _
    7.               0&, hNewKey, lRetVal)
    8.     RegCloseKey (hNewKey)
    9. End Function

    And this is the code to use the function:
    VB Code:
    1. For i = 1 To 3
    2.         strValue = RegGetValue$(HKEY_CURRENT_USER, strSubKey, arrSites(i))
    3.         If strValue = "" Then
    4.             frmMain.CreateNewKey strSubKey, HKEY_CURRENT_USER
    5.             frmMain.SetKeyValue strSubKey, arrSites(i), "", 3
    6.         Else
    7.         End If
    8.     Next


    Does this look like I'm doing it right?
    CodeBank: Launch IE

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Location
    Chicago
    Posts
    136

    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?
    CodeBank: Launch IE

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width