jeudi 8 septembre 2016

If registry exist, continue, else open form?

I'm still working towards becoming proficient in VB and I thought this part would be easier, and it probably is if you know what your doing. But I have a registry key my app creates on first run. Now when ran again I wanted it to check if the key exist, if so then continue to run the application and if not show a form to set initial settings. I've had it work if the key doesn't exist but then it continues to popup the form even if the key exist afterwards.

Dim regKey As Microsoft.Win32.RegistryKey
regKey = Registry.LocalMachine.OpenSubKey("HKCU\Software\Tool Inc\Inventory\Firstrun", True)

  If regKey Is Nothing Then
     Dim Settings As New frmSettings
     Settings.ShowDialog()
  End If

Aucun commentaire:

Enregistrer un commentaire