cdoverlaw Posted July 5, 2004 Posted July 5, 2004 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 Quote
Administrators PlausiblyDamp Posted July 5, 2004 Administrators Posted July 5, 2004 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 didn't exist End If End Sub Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
cdoverlaw Posted July 5, 2004 Author Posted July 5, 2004 so how would i check local machine/software/revoshift/webhost toolbox/ has a string called "valid" and that value is equal to "true" Quote
Administrators PlausiblyDamp Posted July 5, 2004 Administrators Posted July 5, 2004 Not that different from above 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 Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
cdoverlaw Posted July 5, 2004 Author Posted July 5, 2004 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 Quote
Administrators PlausiblyDamp Posted July 5, 2004 Administrators Posted July 5, 2004 If you step through in the debugger does it go to the line If rk.GetValue("valid") = "true" Then if so what is the value of rk.GetValue("valid") ? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
cdoverlaw Posted July 5, 2004 Author Posted July 5, 2004 yup, it gets up to there and then stops workin i also tried 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 Quote
Administrators PlausiblyDamp Posted July 5, 2004 Administrators Posted July 5, 2004 If you put a watch on the value rk.GetValue("valid") what appears in the debugger? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
cdoverlaw Posted July 5, 2004 Author Posted July 5, 2004 (edited) here is the test program, i cant get my debugger to work properlyregtest.zip Edited July 5, 2004 by PlausiblyDamp Quote
Administrators PlausiblyDamp Posted July 5, 2004 Administrators Posted July 5, 2004 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.... Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.