Anzahl aller Einträge eines Registryschlüssels ermitteln
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 CountValueNames(ByVal Root As HKEY_ROOTS, ByVal Path As String) As Integer
Try
Select Case Root
Case 0 : Return Registry.ClassesRoot.OpenSubKey(Path).ValueCount
Case 1 : Return Registry.CurrentUser.OpenSubKey(Path).ValueCount
Case 2 : Return Registry.LocalMachine.OpenSubKey(Path).ValueCount
Case 3 : Return Registry.Users.OpenSubKey(Path).ValueCount
Case 4 : Return Registry.CurrentConfig.OpenSubKey(Path).ValueCount
Case 5 : Return Registry.CurrentUser.OpenSubKey("Software\VB and VBA Program Settings\" & Path).ValueCount
Case Else : Return 0
End Select
Catch ex As Exception
Return 0
End Try
End Function
Kommentare zum Snippet