Question : WMI registry vb.net

err.Message = "Unparsable query. "

is showing for the following code. i just want to monitor any change in a registry key from that code. i donno why the error arises. please help

thanx
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
Try

            Dim query As New WqlEventQuery( _
                "SELECT * FROM RegistryValueChangeEvent WHERE " & _
                "KeyPath = 'HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip'" & _
                " AND ValueName = 'Path'")

            Dim watcher As New ManagementEventWatcher(query)
            'Console.WriteLine("Waiting for an event...")

            Dim eventObj As ManagementBaseObject = watcher.WaitForNextEvent()

            Console.WriteLine("{0} event occurred.", eventObj("__CLASS"))

            ' Cancel the event subscription
            watcher.Stop()

        Catch err As ManagementException

            MessageBox.Show("An error occurred while trying to receive an event: " & err.Message)
        End Try

Answer : WMI registry vb.net

try KeyPath = 'SOFTWARE\\7-Zip' rather than KeyPath = 'SOFTWARE\7-Zip'
Random Solutions  
 
programming4us programming4us