Private Function Registry_Read(Key_Path, Key_Name) As Variant
On Error Resume Next
Dim Registry As Object
Set Registry = CreateObject("WScript.Shell")
Registry_Read = Registry.RegRead(Key_Path & Key_Name)
End Function
Private Sub Registry_Write(Key_Path As String, Key_Name As String, Key_Value As Variant, Optional Key_Type As String)
On Error Resume Next
'Key Type list (Use within string, ex. "
' REG_DWORD")
'----------------
'REG_BINARY - This type stores the value
' as raw binary data. Most hardware compon
' ent information is stored as binary data
' , and can be displayed in an editor in h
' exadecimal format.
'REG_DWORD - This type represents the da
' ta by a four byte number and is commonly
' used for boolean values, such as "0" is
' disabled and "1" is enabled. Additionall
' y many parameters for device driver and
' services are this type, and can be displ
' ayed in REGEDT32 in binary, hexadecimal
' and decimal format, or in REGEDIT in hex
' adecimal and decimal format.
'REG_EXPAND_SZ - This type is an expanda
' ble data string that is string containin
' g a variable to be replaced when called
' by an application. For example, for the
' following value, the string "%SystemRoot
' %" will replaced by the actual location
' of the directory containing the Windows
' NT system files. (This type is only avai
' lable using an advanced registry editor
' such as REGEDT32)
'REG_MULTI_SZ - This type is a multiple
' string used to represent values that con
' tain lists or multiple values, each entr
' y is separated by a NULL character. (Thi
' s type is only available using an advanc
' ed registry editor such as REGEDT32)
'REG_SZ - This type is a standard string
' , used to represent human readable text
' values.
'Other data types not available through
' the standard registry editors include:
'REG_DWORD_LITTLE_ENDIAN - A 32-bit numb
' er in little-endian format.
'REG_DWORD_BIG_ENDIAN - A 32-bit number
' in big-endian format.
'REG_LINK - A Unicode symbolic link. Use
' d internally; applications should not us
' e this type.
'REG_NONE - No defined value type.
'REG_QWORD - A 64-bit number.
'REG_QWORD_LITTLE_ENDIAN - A 64-bit numb
' er in little-endian format.
'REG_RESOURCE_LIST - A device-driver res
' ource list.
Dim Registry As Object
Dim Registry_Value As Variant
Set Registry = CreateObject("WScript.Shell")
Registry_Value = Registry_Read(Key_Path, Key_Name)
If Key_Type = "" Then
'REG_SZ is the default.
Registry.RegWrite Key_Path & Key_Name, Key_Value
Else
Registry.RegWrite Key_Path & Key_Name, Key_Value, Key_Type
End If
End Sub
Private Sub Form_Activate()
'This is only an example of a registry entry.
MsgBox Registry_Read("HKEY_LOCAL_MACHINEMsgBox Registry_Read("HKEY_Local_MACHINE\Software\Microsoft\Internet Explorer\", "W2kVersion")\Software\Microsoft\Internet Explorer\", "W2kVersion")
Registry_Write "HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\RUN\", "Test", 1, "REG_DWORD"
End Sub