Registry key to exist

cdoverlaw

Well-known member
Joined
Oct 11, 2003
Messages
146
Hi, how do i make my program check to see if a registry key exists before it allows my program to execute, this is because i want the program to check its been installed correctly before it launches
I would create this registry key in the installation, so i need to know how do i make the installer ask for a registration key which allows software to be installed (installer being made by the vb.net installer maker thing

jonathan
 
Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim rk As Microsoft.Win32.RegistryKey
        rk = Microsoft.Win32.Registry.Users.OpenSubKey("Test")    your key here

        If rk Is Nothing Then
            key didnt exist
        End If
    End Sub
 
so how would i check
local machine/software/revoshift/webhost toolbox/
has a string called
"valid"
and that value is equal to
"true"
 
Not that different from above
Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim rk As Microsoft.Win32.RegistryKey
        rk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("software/revoshift/webhost toolbox/")

        If Not rk Is Nothing Then
            key did exist
            If rk.GetValue("valid") = "true" Then
                value is correct
            End If
        End If
    End Sub
 
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim rk As Microsoft.Win32.RegistryKey

        rk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("software/revoshift/webhost toolbox/")



        If Not rk Is Nothing Then

            MsgBox("Ah")


        End If
        If rk.GetValue("valid") = "true" Then

            MsgBox("Yippe")

        End If

    End Sub

isnt doing anything
 
If you step through in the debugger does it go to the line
Code:
If rk.GetValue("valid") = "true" Then
if so what is the value of rk.GetValue("valid") ?
 
yup, it gets up to there and then stops workin

i also tried
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim rk As Microsoft.Win32.RegistryKey

        rk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("software/revoshift/webhost toolbox/")



        If Not rk Is Nothing Then

            MsgBox("Ah")

            If rk.GetValue("valid") = "true" Then

                MsgBox("Yippe")

            End If

        End If
    End Sub
 
here is the test program, i cant get my debugger to work properly
 

Attachments

Last edited by a moderator:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim rk As Microsoft.Win32.RegistryKey

rk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("software\revoshift\webhost toolbox\")

If Not rk Is Nothing Then
    If rk.GetValue("valid") = "true" Then
        MessageBox.Show("Yippe")
    End If
End If
End Sub
I had the slashes the wrong way round in my earlier post :), what you get for not testing....
 
Back
Top