system.nullreferenceexception?? why?

Goggy

Newcomer
Joined
May 10, 2006
Messages
8
Visual Basic:
        Dim objRegistry As RegistryKey = Registry.ClassesRoot
        Dim objDefaultIcon As RegistryKey = Registry.ClassesRoot
        Dim Names() As String = objRegistry.GetSubKeyNames

        For i As Int32 = 1 To Names.Length - 1
            If Mid(Names(i), 1, 1) <> "." Then Exit For

            objRegistry = objRegistry.OpenSubKey(Names(i))

            objDefaultIcon = objDefaultIcon.OpenSubKey(objRegistry.GetValue("") & "\DefaultIcon")
            Console.WriteLine(Names(i) & objDefaultIcon.GetValue("").ToString)

            ExtentionCollection.Add(i, Names(i))

        Next

the loops runs once...and then i get the error...maybe iam missing something simple...but i dont get it
 
Solved it

Visual Basic:
Dim objRegistry As RegistryKey = Registry.ClassesRoot
        Dim objDefaultIcon As RegistryKey = Registry.ClassesRoot
        Dim Names() As String = objRegistry.GetSubKeyNames

        For i As Int32 = 1 To Names.Length - 1
            If Mid(Names(i), 1, 1) <> "." Then Exit For

            objRegistry = objRegistry.OpenSubKey(Names(i))

            On Error Resume Next

            objDefaultIcon = objDefaultIcon.OpenSubKey(objRegistry.GetValue("") & "\DefaultIcon")
            Console.WriteLine(Names(i) & objDefaultIcon.GetValue("").ToString)

            ExtentionCollection.Add(i, Names(i))

            objRegistry = Registry.ClassesRoot
            objDefaultIcon = Registry.ClassesRoot

        Next
 
Back
Top