Mit dieser Funktion kann man einen Eintrag aus der Registry löschen (Kein Schlüssel).
Imports Microsoft.Win32
Public Enum HKEY_ROOTS As Integer
HKEY_CLASSES_ROOT = 0
HKEY_CURRENT_USER = 1
HKEY_LOCAL_MACHINE = 2
HKEY_USERS = 3
HKEY_CURRENT_CONFIG = 4
VB_AND_VBA_PROGRAM_SETTINGS = 5
End Enum
Public Function RegDelValueName(ByVal Root As HKEY_ROOTS, ByVal Path As String, ByVal ValueName As String) As Boolean
Try
Select Case Root
Case 0 : Registry.ClassesRoot.OpenSubKey(Path, True).DeleteValue(ValueName)
Case 1 : Registry.CurrentUser.OpenSubKey(Path, True).DeleteValue(ValueName)
Case 2 : Registry.LocalMachine.OpenSubKey(Path, True).DeleteValue(ValueName)
Case 3 : Registry.Users.OpenSubKey(Path, True).DeleteValue(ValueName)
Case 4 : Registry.CurrentConfig.OpenSubKey(Path, True).DeleteValue(ValueName)
Case 5 : Registry.CurrentUser.OpenSubKey("Software\VB and VBA Program Settings\" & Path, True).DeleteValue(ValueName)
End Select
Return True
Catch ex As Exception
Return False
End Try
End Function
Kommentare zum Snippet