|
-
Jan 24th, 2004, 08:49 AM
#1
Thread Starter
Supreme User
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.
-
Jan 24th, 2004, 08:53 AM
#2
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
-
Jan 24th, 2004, 09:00 AM
#3
-= B u g S l a y e r =-
this is the place...that it will always be in : HKEY_CURRENT_USER\Software\Microsoft\Visual Basic\6.0\RecentFiles
-
Jan 24th, 2004, 09:01 AM
#4
Thread Starter
Supreme User
Thanks peet, i was just looking for it....
-
Jan 24th, 2004, 09:06 AM
#5
Thread Starter
Supreme User
Umm,
DeleteSetting
and
RegDeleteKey
doesnt work. Which should i use to remove the keys, is there something different to the two above?
-
Jan 24th, 2004, 09:14 AM
#6
-= B u g S l a y e r =-
no, that will not work.
the registry functions provided by vb only affects the HKEY_CURRENT_USER\Software\VB and VBA Program Settings key.
-
Jan 24th, 2004, 09:17 AM
#7
Thread Starter
Supreme User
so how could i delete the keys? is it possible?
-
Jan 24th, 2004, 09:30 AM
#8
-= B u g S l a y e r =-
yes, I did a sample here
VB Code:
Option Explicit
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
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
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
Private Const REG_SZ = 1 ' Unicode nul terminated string
Private Const REG_DWORD = 4 ' 32-bit number
Private Const ERROR_SUCCESS = 0&
Public Enum pvpHK
HKEY_CLASSES_ROOT = &H80000000
HKEY_CURRENT_USER = &H80000001
HKEY_LOCAL_MACHINE = &H80000002
HKEY_USERS = &H80000003
HKEY_PERFORMANCE_DATA = &H80000004
End Enum
Private Const pvpRunHKey = "Software\Microsoft\Windows\CurrentVersion\Run"
Private Const pvpVB6MRUKey = "Software\Microsoft\Visual Basic\6.0\RecentFiles"
Private Sub savestring(ByVal hKey As Long, strPath As String, strValue As String, strData As String)
Dim keyhand As Long
Dim r As Long
r = RegCreateKey(hKey, strPath, keyhand)
r = RegSetValueEx(keyhand, strValue, 0, REG_SZ, ByVal strData, Len(strData))
If r = 87 Then
'Tom streng! -> må slettes
DeleteValue hKey, strPath, strValue
End If
r = RegCloseKey(keyhand)
End Sub
Private Function DeleteValue(ByVal hKey As Long, ByVal strPath As String, ByVal strValue As String)
Dim keyhand As Long
Dim r As Long
r = RegOpenKey(hKey, strPath, keyhand)
r = RegDeleteValue(keyhand, strValue)
r = RegCloseKey(keyhand)
End Function
Public Sub DeleteKey(ByVal hKey As Long, ByVal sKeyName As String)
Dim lRetVal As Long
lRetVal = RegDeleteKey(hKey, sKeyName)
End Sub
Public Function RunAtStartup(sAppTitle As String, strsAppName As String)
savestring pvpHK.HKEY_CURRENT_USER, pvpRunHKey, sAppTitle, sAppName
End Function
'set app as startup
'Private Sub Command1_Click()
' RunAtStartup App.Title, App.Path & "\" & App.EXEName & ".EXE"
'End Sub
'Delete vb6 recent file list
Private Sub Command1_Click()
DeleteKey pvpHK.HKEY_CURRENT_USER, pvpVB6MRUKey
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
-
Jan 24th, 2004, 09:32 AM
#9
Thread Starter
Supreme User
Thanks, i thought it would of been a simpler procedure......
-
Jan 24th, 2004, 09:35 AM
#10
-= B u g S l a y e r =-
mmm might be other ways....
this is the short version :
VB Code:
Option Explicit
Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
Public Sub DeleteKey(ByVal hKey As Long, ByVal sKeyName As String)
Dim lRetVal As Long
lRetVal = RegDeleteKey(hKey, sKeyName)
End Sub
'Delete vb6 recent file list
Private Sub Command1_Click()
DeleteKey &H80000001, "Software\Microsoft\Visual Basic\6.0\RecentFiles"
End Sub
-
Jan 24th, 2004, 09:39 AM
#11
Frenzied Member
or you could just use my project from the codebank....
-
Jan 24th, 2004, 09:43 AM
#12
Thread Starter
Supreme User
Thanks for the code peet, thanks agmorgan for suggesting his example (and letting me know to compile it on order to work).
Cheers guys!
-
Jan 24th, 2004, 03:09 PM
#13
Thread Starter
Supreme User
How do you delete an individual value? I tried :
VB Code:
Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Private Function DeleteValue(ByVal hKey As Long, ByVal strPath As String, ByVal strValue As String)
Dim keyhand As Long
Dim r As Long
r = RegOpenKey(hKey, strPath, keyhand)
r = RegDeleteValue(keyhand, strValue)
r = RegCloseKey(keyhand)
End Function
[B]DeleteValue[/B] &H80000001, "HKEY_CURRENT_USER\Software\Game Maker\Version 5\Preferences\Recent0"
Thanks, it errors "Argument Not Optional" (Bold highlighted)
-
Jan 24th, 2004, 03:51 PM
#14
-= B u g S l a y e r =-
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...
-
Jan 24th, 2004, 04:34 PM
#15
Thread Starter
Supreme User
-
Jan 24th, 2004, 04:48 PM
#16
Thread Starter
Supreme User
Where do i place the strValue?
VB Code:
DeleteValue &H80000001, "HKEY_CURRENT_USER\Software\Game Maker\Version 5\Preferences\Recent0, [B]strValue[/B]"
Thanks
-
Jan 24th, 2004, 08:35 PM
#17
-= B u g S l a y e r =-
VB Code:
DeleteValue &H80000001, "HKEY_CURRENT_USER\Software\Game Maker\Version 5\Preferences\Recent0", "NameOFTeValue"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|