'DECLARATIONS Private m_sWebsite As String Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long Private Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, lpSecurityAttributes As Any, hKeyHandle As Long, lpdwDisposition As Long) As Long Private Declare Function RegQueryValueExString Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, hKeyHandle 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 Private Const ERROR_SUCCESS = 0& Private Const HKEY_CLASSES_ROOT = &H80000000 Private Const HKEY_CURRENT_CONFIG = &H80000005 Private Const HKEY_CURRENT_USER = &H80000001 Private Const HKEY_DYN_DATA = &H80000006 Private Const HKEY_LOCAL_MACHINE = &H80000002 Private Const HKEY_PERFORMANCE_DATA = &H8000003 Private Const KEY_CREATE_SUB_KEY = &H4 Private Const KEY_ENUMERATE_SUB_KEYS = &H8 Private Const KEY_QUERY_VALUE = &H1 Private Const KEY_SET_VALUE = &H1 Private Const KEY_NOTIFY = &H10 Private Const KEY_CREATE_LINK = &H20 Private Const REG_OPTION_NON_VOLATILE = 0 Private Const REG_SZ = 1 Private Const STANDARD_RIGHTS_ALL = &H1F0000 Private Const SYNCHRONIZE = &H100000 Private Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE)) 'REGISTRY FUNCTIONS Public Function fnGetRegistryKey(sKey As String, sEntry As String, Optional bHKeyClassesRoot As Boolean = False, Optional bHKeyCurrentConfig As Boolean = False, Optional bHKeyCurrentUser As Boolean = True, Optional bHKeyDynamicData As Boolean = False, Optional bHKeyLocalMachine As Boolean = False, Optional bHKeyPerformanceData As Boolean = False, Optional bHKeyUsers As Boolean = False, Optional bDirectory As Boolean = False) As String Const BUFFER_LENGTH = 255 Dim sKeyName As String Dim sReturnBuffer As String Dim lBufLen As Long Dim lReturn As Long Dim hKeyHandle As Long Dim lKeyType As Long sReturnBuffer = Space(BUFFER_LENGTH) lBufLen = BUFFER_LENGTH lKeyType = fnDetermineKeyType(bHKeyClassesRoot, bHKeyCurrentConfig, bHKeyCurrentUser, bHKeyDynamicData, bHKeyLocalMachine, bHKeyPerformanceData, bHKeyUsers) lReturn = RegOpenKeyEx(lKeyType, sKey, 0, KEY_ALL_ACCESS, hKeyHandle) If lReturn = ERROR_SUCCESS Then lReturn = RegQueryValueExString(hKeyHandle, sEntry, 0, 0, sReturnBuffer, lBufLen) If lReturn = ERROR_SUCCESS Then sReturnBuffer = Trim$(Left$(sReturnBuffer, lBufLen - 1)) If bDirectory Then If Right$(sReturnBuffer, 1) <> "\" Then sReturnBuffer = sReturnBuffer & "\" End If End If fnGetRegistryKey = sReturnBuffer & "\" Else fnGetRegistryKey = "" End If Else fnGetRegistryKey = "" End If RegCloseKey hKeyHandle End Function Public Function fnDetermineKeyType(bHKeyClassesRoot As Boolean, bHKeyCurrentConfig As Boolean, bHKeyCurrentUser As Boolean, bHKeyDynamicData As Boolean, bHKeyLocalMachine As Boolean, bHKeyPerformanceData As Boolean, bHKeyUsers As Boolean) As Long Dim lResult As Long If bHKeyClassesRoot Then lResult = HKEY_CLASSES_ROOT ElseIf bHKeyCurrentConfig Then lResult = HKEY_CURRENT_CONFIG ElseIf bHKeyCurrentUser Then lResult = HKEY_CURRENT_USER ElseIf bHKeyDynamicData Then lResult = HKEY_DYN_DATA ElseIf bHKeyLocalMachine Then lResult = HKEY_LOCAL_MACHINE ElseIf bHKeyPerformanceData Then lResult = HKEY_PERFORMANCE_DATA ElseIf bHKeyUsers Then lResult = HKEY_USERS End If fnDetermineKeyType = lResult End Function