Option Explicit Public Const SETTINGS_FILE As String = "settings_.dat" Private Sub Form_Load() LoadSettings AddToStartup End Sub '======================== ' Загрузка настроек '======================== Public Sub LoadSettings() Dim f As Integer Dim line1 As String If Dir$(SETTINGS_FILE) = "" Then enableIcons.Value = 1 Exit Sub End If f = FreeFile Open SETTINGS_FILE For Input As #f If Not EOF(f) Then Line Input #f, line1 If Trim(line1) = "1" Then enableIcons.Value = 1 Else enableIcons.Value = 0 End If End If Close #f 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 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 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 AddToStartup() Dim WSH As Object Dim FullPath As String Dim KeyPath As String Dim Existing As String Set WSH = CreateObject("WScript.Shell") ' полный путь к exe 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 Existing = WSH.RegRead(KeyPath) ' если ключа нет — создаём If Err.Number <> 0 Then Err.Clear WSH.RegWrite KeyPath, FullPath End If End Sub