i foud this code , its work well in windows 7 but when i run project in windows xp its says i must use New keyword but when i use New its gives error at regkey.GetValueNames and RegistryKey = Registry.LocalMachine and regBaseKey.OpenSubKey("SOFTWARE\MyApp", False
Imports Microsoft.Win32

Public Class mform




Dim regBaseKey As RegistryKey = Registry.LocalMachine

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Dim regkey As RegistryKey = regBaseKey.OpenSubKey("SOFTWARE\MyApp", False)
    ListBox2.Items.AddRange(regkey.GetValueNames)
End Sub
end class

when i add New keyword , its right like this ?

Imports Microsoft.Win32

Public Class mform


    Dim regBaseKey new As RegistryKey = Registry.LocalMachine

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim regkey As new RegistryKey = regBaseKey.OpenSubKey("SOFTWARE\MyApp", False)
        ListBox2.Items.AddRange(regkey.GetValueNames)
    End Sub

Dim regBaseKey new As RegistryKey = Registry.LocalMachine

Instead of

Dim regBaseKey new As RegistryKey = Registry.LocalMachine

try

Dim regBaseKey As New RegistryKey = Registry.LocalMachine

You might also need to set permnissions when opening your subkey.

.OpenSubKey(strProgramName, RegistryKeyPermissionCheck.ReadWriteSubTree)

Edited 4 Years Ago by thines01

This article has been dead for over six months. Start a new discussion instead.