Results 1 to 3 of 3

Thread: Write binary values to the registry

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Posts
    15

    Question

    Hello all!
    I am trying to find out what is the best way to write binary (REG_BINARY) type values to the registry.
    Say I have the following: 42, 41, 42, 41, 00, 31, 45, 46, 45, 00 (= BABA.1EFE.) and I would like to write all of that to the registry for a REG_BINARY type value.
    Any ideas?? Any help would be GREATLY appreciated.
    Daniel Pinzas

  2. #2
    Guest
    Use RegSetValueEx
    Code:
    Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal HKEY As Long) As Long
    Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal HKEY As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal HKEY As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
    Const HKEY_CURRENT_USER = &H80000001
    Const REG_BINARY = 3
    
    Sub SaveSettingEx(HKEY As Long, sPath As String, sValue As String, sData As String)
        Dim KeyHand As Long
        Call RegCreateKey(HKEY, sPath, KeyHand)
        Call RegSetValueEx(KeyHand&, sValue, 0, REG_BINARY, ByVal sData, Len(sData))
        Call RegCloseKey(KeyHand&)
    End Sub
    
    Private Sub Command1_Click()
        SaveSettingEx HKEY_CURRENT_USER, "Software\BinaryTesting", "BinaryValue", "BABA.1EFE"
    End Sub

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Posts
    15

    Talking

    It worked!!

    Thanks a whole bunch.
    Daniel Pinzas

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