Results 1 to 17 of 17

Thread: Delete VB MRU Project list?[RESOLVED]

  1. #1

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253

    Delete VB MRU Project list?[RESOLVED]

    I wanted to make a simple tool to clear the MRU project list, without having to manually go through the registry. Thing is, how would i know the path for the key on the target users computer, as they will have VB installed in different locations. Or does this not matter?
    Last edited by Madboy; Jan 24th, 2004 at 03:29 PM.

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    The registry entries will always be in the same place.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    this is the place...that it will always be in : HKEY_CURRENT_USER\Software\Microsoft\Visual Basic\6.0\RecentFiles
    -= a peet post =-

  4. #4

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253
    Thanks peet, i was just looking for it....

  5. #5

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253
    Umm,

    DeleteSetting

    and

    RegDeleteKey

    doesnt work. Which should i use to remove the keys, is there something different to the two above?

  6. #6
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    no, that will not work.

    the registry functions provided by vb only affects the HKEY_CURRENT_USER\Software\VB and VBA Program Settings key.
    -= a peet post =-

  7. #7

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253
    so how could i delete the keys? is it possible?

  8. #8
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    yes, I did a sample here

    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
    4. Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    5. Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
    6. Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
    7. Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    8. Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
    9. Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
    10. Private Const REG_SZ = 1                         ' Unicode nul terminated string
    11. Private Const REG_DWORD = 4                      ' 32-bit number
    12. Private Const ERROR_SUCCESS = 0&
    13.  
    14.  
    15. Public Enum pvpHK
    16.     HKEY_CLASSES_ROOT = &H80000000
    17.     HKEY_CURRENT_USER = &H80000001
    18.     HKEY_LOCAL_MACHINE = &H80000002
    19.     HKEY_USERS = &H80000003
    20.     HKEY_PERFORMANCE_DATA = &H80000004
    21. End Enum
    22.  
    23. Private Const pvpRunHKey = "Software\Microsoft\Windows\CurrentVersion\Run"
    24. Private Const pvpVB6MRUKey = "Software\Microsoft\Visual Basic\6.0\RecentFiles"
    25.  
    26.  
    27. Private Sub savestring(ByVal hKey As Long, strPath As String, strValue As String, strData As String)
    28.     Dim keyhand As Long
    29.     Dim r As Long
    30.     r = RegCreateKey(hKey, strPath, keyhand)
    31.     r = RegSetValueEx(keyhand, strValue, 0, REG_SZ, ByVal strData, Len(strData))
    32.     If r = 87 Then
    33.         'Tom streng! -> må slettes
    34.         DeleteValue hKey, strPath, strValue
    35.     End If
    36.     r = RegCloseKey(keyhand)
    37. End Sub
    38.  
    39. Private Function DeleteValue(ByVal hKey As Long, ByVal strPath As String, ByVal strValue As String)
    40.     Dim keyhand As Long
    41.     Dim r As Long
    42.     r = RegOpenKey(hKey, strPath, keyhand)
    43.     r = RegDeleteValue(keyhand, strValue)
    44.     r = RegCloseKey(keyhand)
    45. End Function
    46.  
    47. Public Sub DeleteKey(ByVal hKey As Long, ByVal sKeyName As String)
    48.     Dim lRetVal As Long
    49.     lRetVal = RegDeleteKey(hKey, sKeyName)
    50. End Sub
    51.  
    52. Public Function RunAtStartup(sAppTitle As String, strsAppName As String)
    53.          savestring pvpHK.HKEY_CURRENT_USER, pvpRunHKey, sAppTitle, sAppName
    54. End Function
    55.  
    56. 'set app as startup
    57. 'Private Sub Command1_Click()
    58. '    RunAtStartup App.Title, App.Path & "\" & App.EXEName & ".EXE"
    59. 'End Sub
    60.  
    61. 'Delete vb6 recent file list
    62. Private Sub Command1_Click()
    63.     DeleteKey pvpHK.HKEY_CURRENT_USER, pvpVB6MRUKey
    64. End Sub

    hehe not all that code is needed in order to delete the key, but it shows you how its done. you do the deleting of the code you do not need
    -= a peet post =-

  9. #9

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253
    Thanks, i thought it would of been a simpler procedure......

  10. #10
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    mmm might be other ways....


    this is the short version :

    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
    4.  
    5. Public Sub DeleteKey(ByVal hKey As Long, ByVal sKeyName As String)
    6.     Dim lRetVal As Long
    7.     lRetVal = RegDeleteKey(hKey, sKeyName)
    8. End Sub
    9.  
    10. 'Delete vb6 recent file list
    11. Private Sub Command1_Click()
    12.     DeleteKey &H80000001, "Software\Microsoft\Visual Basic\6.0\RecentFiles"
    13. End Sub
    -= a peet post =-

  11. #11
    Frenzied Member agmorgan's Avatar
    Join Date
    Dec 2000
    Location
    Lurking
    Posts
    1,383
    or you could just use my project from the codebank....

  12. #12

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253
    Thanks for the code peet, thanks agmorgan for suggesting his example (and letting me know to compile it on order to work).

    Cheers guys!

  13. #13

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253
    How do you delete an individual value? I tried :

    VB Code:
    1. Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
    2.  
    3. Private Function DeleteValue(ByVal hKey As Long, ByVal strPath As String, ByVal strValue As String)
    4.     Dim keyhand As Long
    5.     Dim r As Long
    6.     r = RegOpenKey(hKey, strPath, keyhand)
    7.     r = RegDeleteValue(keyhand, strValue)
    8.     r = RegCloseKey(keyhand)
    9. End Function
    10.  
    11. [B]DeleteValue[/B] &H80000001, "HKEY_CURRENT_USER\Software\Game Maker\Version 5\Preferences\Recent0"

    Thanks, it errors "Argument Not Optional" (Bold highlighted)

  14. #14
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    it means you have to feed the DeleteValue function with all parameters.

    you left out DeleteValue strValue, strValue is the name of the Value in the HKEY_CURRENT_USER\Software\Game Maker\Version 5\Preferences\Recent0 key that you want deleted...
    -= a peet post =-

  15. #15

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253
    Doesnt work for me

  16. #16

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253
    Where do i place the strValue?

    VB Code:
    1. DeleteValue &H80000001, "HKEY_CURRENT_USER\Software\Game Maker\Version 5\Preferences\Recent0, [B]strValue[/B]"



    Thanks

  17. #17
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    VB Code:
    1. DeleteValue &H80000001, "HKEY_CURRENT_USER\Software\Game Maker\Version 5\Preferences\Recent0", "NameOFTeValue"
    -= a peet post =-

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width