Results 1 to 4 of 4

Thread: SaveSettings/GetSettings not working

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 1999
    Posts
    1

    Question SaveSettings/GetSettings not working

    HI,
    I installed VB6 on Windows 2000 proffessional edition. In the vb project if i use SaveSettings or GetSettings functions, they are not working. When i run the project i'm getting (SaveSettings,GetSettings) function not found error. It's interesting, i had installed vb6 sp5 even though it's not working. May be some dll wasn't registered properly on my vb installation on Windows 2000 platform. I couldn't find which dll it was? Is there any one face this kind of problem, please let me know the way to resolve this bug.
    thank you and have a good day,
    Ram

  2. #2
    Hyperactive Member Jason Badon's Avatar
    Join Date
    Feb 2001
    Location
    Colorado
    Posts
    329
    put this code in a module

    VB Code:
    1. Private Const REG_OPTION_NON_VOLATILE = 0
    2. Private Const REG_SZ As Long = 1
    3. Private Const REG_BINARY = 3
    4. Private Const REG_DWORD As Long = 4
    5.  
    6. Private Const READ_CONTROL = &H20000
    7. Private Const SYNCHRONIZE = &H100000
    8. Private Const KEY_ALL_ACCESS As Long = &H3F
    9. Private Const KEY_QUERY_VALUE As Long = &H1
    10. Private Const KEY_ENUMERATE_SUB_KEYS As Long = &H8
    11. Private Const KEY_NOTIFY As Long = &H10
    12. Private Const KEY_READ = ((READ_CONTROL Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE))
    13.  
    14. Enum RegistryRootConstants
    15.     HKEY_Classes_Root = &H80000000
    16.     HKEY_Current_User = &H80000001
    17.     HKEY_Local_Machine = &H80000002
    18.     HKEY_Users = &H80000003
    19.     HKEY_Performance_Data = &H80000004
    20.     HKEY_Current_Config = &H80000005
    21.     HKEY_Dyn_Data = &H80000006
    22. End Enum
    23.  
    24.  
    25.  
    26.  
    27.  
    28.  
    29. Private Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias _
    30.     "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, _
    31.     ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions _
    32.     As Long, ByVal samDesired As Long, ByVal lpSecurityAttributes _
    33.     As Long, phkResult As Long, lpdwDisposition As Long) As Long
    34.  
    35. Private Declare Function RegSetValueExString Lib "advapi32.dll" Alias _
    36.     "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, _
    37.     ByVal Reserved As Long, ByVal dwType As Long, ByVal lpValue As _
    38.     String, ByVal cbData As Long) As Long
    39.  
    40. Private Declare Function RegQueryValueExString Lib "advapi32.dll" Alias _
    41.     "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As _
    42.     String, ByVal lpReserved As Long, lpType As Long, ByVal lpData _
    43.     As String, lpcbData As Long) As Long
    44.  
    45. Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias _
    46.     "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, _
    47.     ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As _
    48.     Long) As Long
    49.  
    50. Private Declare Function RegQueryValueExNULL Lib "advapi32.dll" Alias _
    51.     "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As _
    52.     String, ByVal lpReserved As Long, lpType As Long, ByVal lpData _
    53.     As Long, lpcbData As Long) As Long
    54.    
    55. Private Declare Function RegCloseKey Lib "advapi32.dll" _
    56.     (ByVal hKey As Long) As Long
    57.  
    58.  
    59.  
    60.  
    61.  
    62.  
    63.  
    64. Public Sub SaveSetting(ByVal szRegistrySection As String, ByVal szRegistryKey As String, ByVal szRegistrySetting As String)
    65.     Dim lReturnValue As Long
    66.     Dim hKey As Long
    67.  
    68.     lReturnValue = RegCreateKeyEx(HKEY_Local_Machine, szRegistrySection, 0&, vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0&, hKey, lReturnValue)
    69.     lReturnValue = RegSetValueExString(hKey, szRegistryKey, 0&, REG_SZ, szRegistrySetting, Len(szRegistrySetting))
    70.     RegCloseKey hKey
    71. End Sub
    72.  
    73.  
    74. Public Function GetSetting(ByVal szRegistrySection As String, ByVal szRegistryKey As String, ByVal szDefaultRegistrySetting As String) As String
    75.     Dim szRegistrySetting As String
    76.     Dim lReturnValue As Long
    77.     Dim lData As Long
    78.     Dim hKey As Long
    79.  
    80.     lReturnValue = RegOpenKeyEx(HKEY_Local_Machine, szRegistrySection, 0, KEY_READ, hKey)
    81.     lReturnValue = RegQueryValueExNULL(hKey, szRegistryKey, 0&, REG_SZ, 0&, lData)
    82.    
    83.     szRegistrySetting = String(lData, 0)
    84.     lReturnValue = RegQueryValueExString(hKey, szRegistryKey, 0&, REG_SZ, szRegistrySetting, lData)
    85.     If lReturnValue = 0 Then
    86.         szRegistrySetting = Left(szRegistrySetting, lData - 1)
    87.     Else
    88.         szRegistrySetting = szDefaultRegistrySetting
    89.     End If
    90.  
    91.     RegCloseKey hKey
    92.    
    93.     GetSetting = szRegistrySetting
    94. End Function

  3. #3
    Tygur
    Guest
    You do realize it's GetSetting and SaveSetting (without the "S" at the end), right?

  4. #4
    Hyperactive Member Jason Badon's Avatar
    Join Date
    Feb 2001
    Location
    Colorado
    Posts
    329
    Tygur I didn't even notice that

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