Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleClear the list of programs in the Start menu's Run command
Keywordsrun command, start menu, clear, command
CategoriesWindows, Tips and Tricks
 
Use the RegOpenKeyEx API function to open the HKEY_CURRENT_USER registry tree's key:

    Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU

Use RegEnumValue to list the values and RegDeleteValue to delete them. Use RegCloseKey to close the key when you are finished. Then reboot.

 
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
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated