detecting if a specific registry key exists

Winston

Well-known member
Joined
Jan 25, 2003
Messages
266
Location
Sydney, Australia
well if the user checks it so that the app will start up in my app
i save the path of the exe to the run in the registry and also savesetting a boolean value that it starts up
but i just realised wat happens if they went to msconfig and unticked it, so theres a bug

so how would i go about instead detect if the specific registry key in the run section of the registry exists

and if it is then check a box
 
Nice and simple ill leave you to set a boolean

Code:
        Try
            Dim oReg As Microsoft.Win32.Registry
            Dim oRegKey As Microsoft.Win32.RegistryKey
            oRegKey = oReg.LocalMachine.OpenSubKey("SOFTWARE\\MyProgram", True)
            If oRegKey.GetValue("MyValue") Is Nothing Then
                MsgBox("Doesnt exist")
            Else
                MsgBox("Does exist")
            End If
            oRegKey.Close()
        Catch
            MsgBox("Error opening Key, Check it exists and you can access the registery")
        End Try

Hope it helps

Andy
 
i dont get a few bits sorry..


this is wat i have changed it




Try
Dim oReg As Microsoft.Win32.Registry
Dim oRegKey As Microsoft.Win32.RegistryKey
oRegKey = oReg.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run" & Application.ProductName, True)
If oRegKey.GetValue(Application.ProductName) Is Nothing Then
MsgBox("Doesnt exist")
Else
MsgBox("Does exist")
End If
oRegKey.Close()
Catch
MsgBox("Error opening Key, Check it exists and you can access the registery")
End Try




is that rite??

whats the subkey suppose to be?
 
Back
Top