Problem writing multiple values to registery

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • method
    New Member
    • Feb 2006
    • 6

    Problem writing multiple values to registery

    Hi all i am usiing this code to write mulitiple values to registery but it only write one value. could any one help me make this code so that it write multiple values to registery. Currently it only writes nickname but not pwd value!!
    I tried this but gave me error :


    Code:
    'Save the value to the registry
        SaveString HKEY_CURRENT_USER, "Software\xyz\" + Text6.Text, "nickname",+Text7.Text "pwd", strString

    complete code :


    Code:
    Const REG_SZ = 1 ' Unicode nul terminated string
    Const REG_BINARY = 3 ' Free form binary
    Const HKEY_CURRENT_USER = &H80000001
    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 RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
    Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData 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
    
    
    
    
    Sub SaveString(hKey As Long, strPath As String, strValue As String, strData As String)
        Dim Ret
        'Create a new key
        RegCreateKey hKey, strPath, Ret
        'Save a string to the key
        RegSetValueEx Ret, strValue, 0, REG_SZ, ByVal strData, Len(strData)
        'close the key
        RegCloseKey Ret
    End Sub
    Sub SaveStringLong(hKey As Long, strPath As String, strValue As String, strData As String)
        Dim Ret
        'Create a new key
        RegCreateKey hKey, strPath, Ret
        'Set the key's value
        RegSetValueEx Ret, strValue, 0, REG_BINARY, CByte(strData), 4
        'close the key
        RegCloseKey Ret
    End Sub
    
    Private Sub Command14_Click()
    'Dim strString As String
        Dim strString As String
        'Ask for a value
        'strString = InputBox("Please enter a value to be saved as a binary value in the registry.", App.Title)
        
    
        'Save the value to the registry
    
    
    [B]    SaveString HKEY_CURRENT_USER, "Software\xyz\" + Text6.Text, "nickname", strString[/B]
    
    '[B]    SaveString HKEY_CURRENT_USER, "Software\xyz\" + Text6.Text, "nickname",+Text7.Text, "pwd", strString[/B] ===> did not work
        
     
    End Sub
  • sashi
    Recognized Expert Top Contributor
    • Jun 2006
    • 1749

    #2
    hi method,

    try this method.. good luck to u my fren..

    SaveString HKEY_CURRENT_US ER, "Software\xyz\" ,trim(Text6.Tex t), "nickname",(tri m(Text7.Text), "pwd", strString

    Comment

    Working...