Option Explicit Private Const SETTINGS_FILE As String = "settings_.dat" Private Sub Form_Load() LoadSettings End Sub '======================== ' Загрузка настроек '======================== Public Sub LoadSettings() Dim f As Integer Dim line1 As String Dim line2 As String If Dir$(SETTINGS_FILE) = "" Then enableIcons.Value = 1 enableStartup.Value = 0 Exit Sub End If f = FreeFile Open SETTINGS_FILE For Input As #f If Not EOF(f) Then Line Input #f, line1 End If If Not EOF(f) Then Line Input #f, line2 End If Close #f If Trim(line1) = "1" Then enableIcons.Value = 1 Else enableIcons.Value = 0 End If If Trim(line2) = "1" Then enableStartup.Value = 1 Else enableStartup.Value = 0 End If End Sub '======================== ' Сохранение настроек '======================== Public Sub SaveSettings() Dim f As Integer f = FreeFile Open SETTINGS_FILE For Output As #f If enableIcons.Value = 1 Then Print #f, "1" Else Print #f, "0" End If If enableStartup.Value = 1 Then Print #f, "1" Else Print #f, "0" End If Close #f End Sub '======================== ' Получить значение enableIcons '======================== Public Function IconsEnabled() As Boolean If enableIcons.Value = 1 Then IconsEnabled = True Else IconsEnabled = False End If End Function '======================== ' OK '======================== Private Sub cmdOK_Click() SaveSettings UpdateStartup Unload Me End Sub '======================== ' Cancel '======================== Private Sub cmdCancel_Click() Unload Me End Sub '======================== ' Reset '======================== Private Sub cmdReset_Click() enableIcons.Value = 1 End Sub '======================== ' Menu Close '======================== Private Sub mnuClose_Click() Unload Me End Sub '======================== ' Реальное переключение '======================== Private Sub enableIcons_Click() Form1.UpdateTreeIcons IconsEnabled End Sub Private Sub UpdateStartup() Dim WSH As Object Dim FullPath As String Dim KeyPath As String Set WSH = CreateObject("WScript.Shell") FullPath = App.Path If Right(FullPath, 1) <> "\" Then FullPath = FullPath & "\" FullPath = FullPath & App.EXEName & ".exe" KeyPath = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\" & App.EXEName On Error Resume Next If enableStartup.Value = 1 Then WSH.RegWrite KeyPath, """" & FullPath & """" Else WSH.RegDelete KeyPath End If End Sub