Private Sub Command1_Click()
Dim hKey As Long
Dim value_name_len As Long
Dim value_name As String
Dim value_data(1 To 1024) As Byte
Dim value_data_len As Long
Dim value_type As Long
Dim value_data_string As String
Dim i As Integer
' Open the key.
If RegOpenKeyEx(HKEY_CURRENT_USER, _
"Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU", _
_
0&, KEY_ALL_ACCESS, hKey) <> ERROR_SUCCESS _
Then
MsgBox "Error opening key."
Exit Sub
End If
' Delete the key's values.
Do
value_name_len = 1024
value_name = Space$(value_name_len)
value_data_len = 1024
If RegEnumValue(hKey, 0, _
value_name, value_name_len, 0, _
value_type, value_data(1), value_data_len) _
<> ERROR_SUCCESS Then Exit Do
' Get the program name the slow way.
value_data_string = ""
For i = 1 To value_data_len - 1
value_data_string = value_data_string & _
Chr$(value_data(i))
Next i
Debug.Print "Removing " & value_data_string
' Remove the value.
value_name = Left$(value_name, value_name_len)
RegDeleteValue hKey, value_name
Loop
' Close the key.
If RegCloseKey(hKey) <> ERROR_SUCCESS Then
MsgBox "Error closing key."
End If
MsgBox "Ok"
End Sub
|