Dim hKey As Long, MainKeyHandle As LongDim rtn As Long, lBuffer As Long, sBuffer As StringDim lBufferSize As LongDim lDataSize As LongDim ByteArray() As Byte

Const DisplayErrorMsg = False

Function SetDWORDValue(SubKey As String, Entry As String, Value As Long)

Call ParseKey(SubKey, MainKeyHandle)

If MainKeyHandle Then rtn = RegOpenKeyEx(MainKeyHandle, SubKey, 0, KEY_WRITE, hKey) 'open the key If rtn = ERROR_SUCCESS Then rtn = RegSetValueExA(hKey, Entry, 0, REG_DWORD, Value, 4) If Not rtn = ERROR_SUCCESS Then If DisplayErrorMsg = True Then MsgBox ErrorMsg(rtn) End If End If rtn = RegCloseKey(hKey) 'close the key Else 'if there was an error opening the key If DisplayErrorMsg = True Then 'if the user want errors displayed MsgBox ErrorMsg(rtn) 'display the error End If End IfEnd If

End FunctionFunction GetDWORDValue(SubKey As String, Entry As String)

Call ParseKey(SubKey, MainKeyHandle)

If MainKeyHandle Then rtn = RegOpenKeyEx(MainKeyHandle, SubKey, 0, KEY_READ, hKey) 'open the key If rtn = ERROR_SUCCESS Then 'if the key could be opened then rtn = RegQueryValueExA(hKey, Entry, 0, REG_DWORD, lBuffer, 4) 'get the value from the registry If rtn = ERROR_SUCCESS Then 'if the value could be retreived then rtn = RegCloseKey(hKey) 'close the key GetDWORDValue = lBuffer 'return the value Else 'otherwise, if the value couldnt be retreived GetDWORDValue = "Error" 'return Error to the user If DisplayErrorMsg = True Then 'if the user wants errors displayed MsgBox ErrorMsg(rtn) 'tell the user what was wrong End If End If Else 'otherwise, if the key couldnt be opened GetDWORDValue = "Error" 'return Error to the user If DisplayErrorMsg = True Then 'if the user wants errors displayed MsgBox ErrorMsg(rtn) 'tell the user what was wrong End If End IfEnd If

If MainKeyHandle Then rtn = RegOpenKeyEx(MainKeyHandle, SubKey, 0, KEY_WRITE, hKey) 'open the key If rtn = ERROR_SUCCESS Then 'if the key was open successfully then lDataSize = Len(Value) ReDim ByteArray(lDataSize) For i = 1 To lDataSize ByteArray(i) = Asc(Mid$(Value, i, 1)) Next rtn = RegSetValueExB(hKey, Entry, 0, REG_BINARY, ByteArray(1), lDataSize) 'write the value If Not rtn = ERROR_SUCCESS Then 'if the was an error writting the value If DisplayErrorMsg = True Then 'if the user want errors displayed MsgBox ErrorMsg(rtn) 'display the error End If End If rtn = RegCloseKey(hKey) 'close the key Else 'if there was an error opening the key If DisplayErrorMsg = True Then 'if the user wants errors displayed MsgBox ErrorMsg(rtn) 'display the error End If End IfEnd If

End Function

Function GetBinaryValue(SubKey As String, Entry As String)

Call ParseKey(SubKey, MainKeyHandle)

If MainKeyHandle Then rtn = RegOpenKeyEx(MainKeyHandle, SubKey, 0, KEY_READ, hKey) 'open the key If rtn = ERROR_SUCCESS Then 'if the key could be opened lBufferSize = 1 rtn = RegQueryValueEx(hKey, Entry, 0, REG_BINARY, 0, lBufferSize) 'get the value from the registry sBuffer = Space(lBufferSize) rtn = RegQueryValueEx(hKey, Entry, 0, REG_BINARY, sBuffer, lBufferSize) 'get the value from the registry If rtn = ERROR_SUCCESS Then 'if the value could be retreived then rtn = RegCloseKey(hKey) 'close the key GetBinaryValue = sBuffer 'return the value to the user Else 'otherwise, if the value couldnt be retreived GetBinaryValue = "Error" 'return Error to the user If DisplayErrorMsg = True Then 'if the user wants to errors displayed MsgBox ErrorMsg(rtn) 'display the error to the user End If End If Else 'otherwise, if the key couldnt be opened GetBinaryValue = "Error" 'return Error to the user If DisplayErrorMsg = True Then 'if the user wants to errors displayed MsgBox ErrorMsg(rtn) 'display the error to the user End If End IfEnd If

End FunctionFunction DeleteKey(KeyName As String)

Call ParseKey(KeyName, MainKeyHandle)

If MainKeyHandle Then rtn = RegOpenKeyEx(MainKeyHandle, KeyName, 0, KEY_WRITE, hKey) 'open the key If rtn = ERROR_SUCCESS Then 'if the key could be opened then rtn = RegDeleteKey(hKey, KeyName) 'delete the key rtn = RegCloseKey(hKey) 'close the key End IfEnd If

If MainKeyHandle Then rtn = RegOpenKeyEx(MainKeyHandle, SubKey, 0, KEY_READ, hKey) 'open the key If rtn = ERROR_SUCCESS Then 'if the key could be opened then sBuffer = Space(255) 'make a buffer lBufferSize = Len(sBuffer) rtn = RegQueryValueEx(hKey, Entry, 0, REG_SZ, sBuffer, lBufferSize) 'get the value from the registry If rtn = ERROR_SUCCESS Then 'if the value could be retreived then rtn = RegCloseKey(hKey) 'close the key sBuffer = Trim(sBuffer) GetStringValue = Left(sBuffer, Len(sBuffer) - 1) 'return the value to the user Else 'otherwise, if the value couldnt be retreived GetStringValue = "Error" 'return Error to the user If DisplayErrorMsg = True Then 'if the user wants errors displayed then MsgBox ErrorMsg(rtn) 'tell the user what was wrong End If End If Else 'otherwise, if the key couldnt be opened GetStringValue = "Error" 'return Error to the user If DisplayErrorMsg = True Then 'if the user wants errors displayed then MsgBox ErrorMsg(rtn) 'tell the user what was wrong End If End IfEnd If

If MainKeyHandle Then rtn = RegCreateKey(MainKeyHandle, SubKey, hKey) 'create the key If rtn = ERROR_SUCCESS Then 'if the key was created then rtn = RegCloseKey(hKey) 'close the key End IfEnd If

End FunctionFunction SetStringValue(SubKey As String, Entry As String, Value As String)

Call ParseKey(SubKey, MainKeyHandle)

If MainKeyHandle Then rtn = RegOpenKeyEx(MainKeyHandle, SubKey, 0, KEY_WRITE, hKey) 'open the key If rtn = ERROR_SUCCESS Then 'if the key was open successfully then rtn = RegSetValueEx(hKey, Entry, 0, REG_SZ, ByVal Value, Len(Value)) 'write the value If Not rtn = ERROR_SUCCESS Then 'if there was an error writting the value If DisplayErrorMsg = True Then 'if the user wants errors displayed MsgBox ErrorMsg(rtn) 'display the error End If End If rtn = RegCloseKey(hKey) 'close the key Else 'if there was an error opening the key If DisplayErrorMsg = True Then 'if the user wants errors displayed MsgBox ErrorMsg(rtn) 'display the error End If End IfEnd If