home *** CD-ROM | disk | FTP | other *** search
-
- Private Function RegUpdate() As String
-
- Dim lonSubkeyHandle As Long
- Dim lonStatus As Long
-
- ' Use the GetSubkeyHandle function to determine the
- ' handle of the subkey given in txtSectionName.
- lonSubkeyHandle = GetSubkeyHandle(txtSectionName.Text)
- If lonSubkeyHandle = -1 Then
- ' Subkey could not be located.
- RegUpdate = "Error - Subkey could not be located"
- Exit Function
- End If
-
- ' Use the RegSetValueEx API function to update the
- ' key's value.
- lonStatus = RegSetValueEx(lonSubkeyHandle, _
- txtKeyName.Text, 0, REG_SZ, ByVal txtValue.Text, _
- Len(txtValue.Text))
-
- ' Check status of the operation.
- If lonStatus <> 0 Then
- RegUpdate = "Error - Key could not be updated"
- Else
- RegUpdate = "Key updated sucessfully"
- End If
-
- ' Close the open subkey with the CloseSubKey
- ' function.
- lonStatus = CloseSubkey(lonSubkeyHandle)
-
- End Function
-
-
- Private Function RegAdd() As String
-
- Dim lonSubkeyHandle As Long
- Dim lonStatus As Long
-
- ' Use the GetSubkeyHandle function to determine the
- ' handle of the subkey given in txtSectionName.
- lonSubkeyHandle = GetSubkeyHandle(txtSectionName.Text)
- If lonSubkeyHandle = -1 Then
- ' Subkey could not be located.
- RegAdd = "Error - Subkey could not be located"
- Exit Function
- End If
-
- ' Use the RegSetValueEx API function to create a
- ' new key and set its value.
- lonStatus = RegSetValueEx(lonSubkeyHandle, _
- txtKeyName.Text, 0, REG_SZ, ByVal txtValue.Text, _
- Len(txtValue.Text))
-
- ' Check status of the operation.
- If lonStatus <> 0 Then
- RegAdd = "Error - Key could not be added"
- Else
- RegAdd = "Key added sucessfully"
- End If
-
- ' Close the open subkey with the CloseSubKey
- ' function.
- lonStatus = CloseSubkey(lonSubkeyHandle)
-
- End Function
-