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

Recommended Answers

All 4 Replies

Dim regBaseKey new As RegistryKey = Registry.LocalMachine

Instead of

Dim regBaseKey new As RegistryKey = Registry.LocalMachine

try

Dim regBaseKey As New RegistryKey = Registry.LocalMachine

Also, make sure you have the most recent .Net framework installed.

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

.OpenSubKey(strProgramName, RegistryKeyPermissionCheck.ReadWriteSubTree)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.