hkey = 
sSubKey=
Dim hkResult as long
Dim lBufferSize As Long

Public Function GetRegistryString(hKey As Long, sSubKey As String, _
                sValueName As String, sValue As String, sDefault As String) As Boolean
    
    Dim iNullPosition As Integer
    
    GetRegistryString = False
    
    Dim hkResult As Long
    Dim lBufferSize As Long

If (RegOpenKeyEx( hKey, sSubKey, 0, KEY_QUERY_VALUE, hkResult)) = ERROR_SUCCESS Then
	
	Call RegQueryValueEx(hkResult, sValueName, 0, 0, 0&, lBufferSize)
	Text1 = left(sValue,RegQueryValueEx(hkResult, sValueName, 0,0,sValue,lBufferSize))
	Call RegCloseKey(hkResult)

End If


Public Function SetRegistryString(hKey As Long, sSubKey As String, _
                                  sValueName As String, sValue As String) As Boolean
                                  
    SetRegistryString = False

    Dim hkResult            As Long
    Dim lpdwDisposition     As Long
    Dim SecurityAttributes  As SECURITY_ATTRIBUTES
    Dim lLength             As Long
    Dim sTempValue          As String
    
    If (RegCreateKeyEx( hKey, sSubKey, 0, "", REG_OPTION_NON_VOLATILE, _
        KEY_SET_VALUE, SecurityAttributes, hkResult, lpdwDisposition)) = ERROR_SUCCESS Then
                
        sTempValue = sValue
        lLength = Len(sTempValue)
        If lLength = 0 Then
            sTempValue = ""
        End If
        If (RegSetValueEx( hkResult, sValueName, 0, REG_SZ, sTempValue, lLength + 1)) = ERROR_SUCCESS Then
        	SetRegistryString = True
        End If
        
    End If
    Call RegCloseKey(hkResult)
        
End Function




Public Function CreateRegistryKey(hKey As Long, sSubKey As String) As Boolean
    'hKey is the handle and sSubKey is the key to create    
    Dim hkResult As Long
    Dim lpdwDisposition As Long
    Dim SecurityAttributes As SECURITY_ATTRIBUTES
    Dim lLength As Long
    Dim sTempValue As String
    
    CreateRegistryKey = False

    If (RegCreateKeyEx( hKey, sSubKey, 0, "", REG_OPTION_NON_VOLATILE, _
        KEY_SET_VALUE, SecurityAttributes, hkResult, lpdwDisposition)) = ERROR_SUCCESS Then
     	Call RegCloseKey(hkResult)
        CreateRegistryKey = True    
    End If
        
End Function


Public Function DeleteRegistryKey(hKey As Long, sSubKey As String, sKey As String) As Boolean
        
    Dim hkResult As Long
 
    DeleteRegistryKey = False

    If (RegOpenKeyEx( hKey, sSubKey, 0, KEY_QUERY_VALUE, hkResult)) = ERROR_SUCCESS Then
        If RegDeleteKey( hkResult, sKey) = ERROR_SUCCESS Then
		DeleteRegistryKey = True
        End If        
    End If
        
End Function
























