Thanks, it works perfectly now. I did originally have an Else in there, but I don't know why I removed it...
Anyway here is the full working code for anyone else stuck on this (doubtful, but who knows
)
vbnet code:
Private Sub TrayIcon_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrayIcon.DoubleClick
'If screensaver is active on double click, delete the SCRNSAVE.EXE value and change ScreenSaveActive to 0
If My.Computer.Registry.GetValue(regkey.ToString, "ScreenSaveActive", "Unknown") = "1" Then
regkey.DeleteValue("SCRNSAVE.EXE")
My.Computer.Registry.SetValue("HKEY_Current_User\Control Panel\Desktop\", "ScreenSaveActive", "0")
TrayIcon.Text = My.Resources.inactive
Else
'Otherwise create the SCRNSAVE.EXE value and change ScreenSaveActive to 1
My.Computer.Registry.SetValue("HKEY_Current_User\Control Panel\Desktop\", "SCRNSAVE.EXE", "C:\Windows\System32\ribbons.scr")
My.Computer.Registry.SetValue("HKEY_Current_User\Control Panel\Desktop\", "ScreenSaveActive", "1")
TrayIcon.Text = My.Resources.active
End If
End Sub