VERSION 5.00
Begin VB.Form fMain 
   ClientHeight    =   5295
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   7485
   ClipControls    =   0   'False
   FillStyle       =   0  'Solid
   FontTransparent =   0   'False
   HasDC           =   0   'False
   Icon            =   "QTask3.frx":0000
   ScaleHeight     =   353
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   499
   WindowState     =   1  'Minimized
   Begin VB.CommandButton eButton 
      CausesValidation=   0   'False
      Height          =   435
      Index           =   4
      Left            =   6360
      TabIndex        =   20
      Top             =   4800
      Visible         =   0   'False
      Width           =   1215
   End
   Begin VB.CommandButton eButton 
      CausesValidation=   0   'False
      Height          =   435
      Index           =   3
      Left            =   5160
      TabIndex        =   19
      Top             =   4800
      Visible         =   0   'False
      Width           =   1215
   End
   Begin QuickTask.ctMenuA ctMenuA1 
      CausesValidation=   0   'False
      Height          =   5055
      Left            =   120
      TabIndex        =   17
      Top             =   120
      Width           =   1335
      _ExtentX        =   2355
      _ExtentY        =   8916
   End
   Begin VB.CommandButton eButtonFreeUp 
      CausesValidation=   0   'False
      Height          =   375
      Left            =   1800
      TabIndex        =   11
      TabStop         =   0   'False
      Top             =   360
      Visible         =   0   'False
      Width           =   1215
   End
   Begin VB.CommandButton eButton 
      CausesValidation=   0   'False
      Height          =   435
      Index           =   2
      Left            =   3960
      TabIndex        =   18
      Top             =   4800
      Width           =   1215
   End
   Begin VB.CommandButton eButton 
      CausesValidation=   0   'False
      Height          =   435
      Index           =   1
      Left            =   2760
      TabIndex        =   21
      Top             =   4800
      Width           =   1215
   End
   Begin VB.CommandButton eButton 
      CausesValidation=   0   'False
      Height          =   435
      Index           =   0
      Left            =   1560
      TabIndex        =   16
      Top             =   4800
      Width           =   1215
   End
   Begin VB.CommandButton eButtonHide 
      Cancel          =   -1  'True
      CausesValidation=   0   'False
      Height          =   375
      Left            =   240
      TabIndex        =   13
      TabStop         =   0   'False
      Top             =   240
      Width           =   1095
   End
   Begin VB.PictureBox iView 
      BackColor       =   &H00FFFFFF&
      CausesValidation=   0   'False
      ClipControls    =   0   'False
      FillStyle       =   0  'Solid
      FontTransparent =   0   'False
      HasDC           =   0   'False
      Height          =   4575
      Left            =   1560
      ScaleHeight     =   301
      ScaleMode       =   3  'Pixel
      ScaleWidth      =   357
      TabIndex        =   7
      TabStop         =   0   'False
      Top             =   120
      Visible         =   0   'False
      Width           =   5415
      Begin VB.CheckBox eCheckBox 
         Appearance      =   0  'Flat
         BackColor       =   &H00FFFFFF&
         CausesValidation=   0   'False
         ForeColor       =   &H00000000&
         Height          =   255
         Index           =   5
         Left            =   120
         TabIndex        =   14
         Top             =   3720
         Value           =   1  'Checked
         Width           =   6000
      End
      Begin VB.CheckBox eCheckBox 
         Appearance      =   0  'Flat
         BackColor       =   &H00FFFFFF&
         CausesValidation=   0   'False
         ForeColor       =   &H00000000&
         Height          =   255
         Index           =   0
         Left            =   120
         TabIndex        =   0
         Top             =   2520
         Width           =   6000
      End
      Begin VB.CheckBox eCheckBox 
         Appearance      =   0  'Flat
         BackColor       =   &H00FFFFFF&
         CausesValidation=   0   'False
         ForeColor       =   &H00000000&
         Height          =   255
         Index           =   1
         Left            =   120
         TabIndex        =   1
         Top             =   2760
         Value           =   1  'Checked
         Width           =   6000
      End
      Begin VB.CheckBox eCheckBox 
         Appearance      =   0  'Flat
         BackColor       =   &H00FFFFFF&
         CausesValidation=   0   'False
         ForeColor       =   &H00000000&
         Height          =   255
         Index           =   2
         Left            =   120
         TabIndex        =   2
         Top             =   3000
         Width           =   6000
      End
      Begin VB.CheckBox eCheckBox 
         Appearance      =   0  'Flat
         BackColor       =   &H00FFFFFF&
         CausesValidation=   0   'False
         ForeColor       =   &H00000000&
         Height          =   255
         Index           =   4
         Left            =   120
         TabIndex        =   4
         Top             =   3480
         Width           =   6000
      End
      Begin VB.CheckBox eCheckBox 
         Appearance      =   0  'Flat
         BackColor       =   &H00FFFFFF&
         CausesValidation=   0   'False
         ForeColor       =   &H00000000&
         Height          =   255
         Index           =   3
         Left            =   120
         TabIndex        =   3
         Top             =   3240
         Width           =   6000
      End
      Begin VB.Label eLabel 
         Alignment       =   2  'Center
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H00000000&
         Height          =   255
         Index           =   4
         Left            =   360
         TabIndex        =   15
         Top             =   4080
         Width           =   5055
      End
      Begin VB.Image eImage 
         Height          =   75
         Index           =   1
         Left            =   240
         Top             =   2160
         Width           =   5010
      End
      Begin VB.Label eLabel 
         Alignment       =   2  'Center
         BackColor       =   &H00FFFFFF&
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   495
         Index           =   3
         Left            =   120
         TabIndex        =   12
         Top             =   1560
         Width           =   5055
      End
      Begin VB.Image eImage 
         Height          =   480
         Index           =   0
         Left            =   1080
         Top             =   600
         Width           =   480
      End
      Begin VB.Label eLabel 
         Alignment       =   2  'Center
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H00000000&
         Height          =   255
         Index           =   2
         Left            =   120
         TabIndex        =   10
         Top             =   1200
         Width           =   5055
      End
      Begin VB.Label eLabel 
         BackColor       =   &H00FFFFFF&
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   255
         Index           =   0
         Left            =   1680
         TabIndex        =   9
         Top             =   600
         Width           =   3135
      End
      Begin VB.Label eLabel 
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H00000000&
         Height          =   255
         Index           =   1
         Left            =   1680
         TabIndex        =   8
         Top             =   840
         Width           =   3135
      End
   End
   Begin VB.ListBox lView 
      CausesValidation=   0   'False
      BeginProperty Font 
         Name            =   "Lucida Console"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   4140
      IntegralHeight  =   0   'False
      Left            =   1560
      MultiSelect     =   2  'Extended
      TabIndex        =   5
      Top             =   120
      Width           =   5415
   End
   Begin VB.ListBox sView 
      CausesValidation=   0   'False
      BeginProperty Font 
         Name            =   "Lucida Console"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   4350
      IntegralHeight  =   0   'False
      Left            =   1560
      Style           =   1  'Checkbox
      TabIndex        =   6
      Top             =   120
      Visible         =   0   'False
      Width           =   5415
   End
   Begin VB.Menu m0 
      Caption         =   "m0"
      Visible         =   0   'False
      Begin VB.Menu mOMenu 
         Caption         =   ""
         Index           =   0
      End
      Begin VB.Menu mOMenu 
         Caption         =   "-"
         Index           =   1
      End
      Begin VB.Menu mOMenu 
         Caption         =   ""
         Index           =   2
      End
      Begin VB.Menu mOMenu 
         Caption         =   "-"
         Index           =   3
      End
      Begin VB.Menu mOMenu 
         Caption         =   ""
         Index           =   4
      End
      Begin VB.Menu mOMenu 
         Caption         =   "-"
         Index           =   5
         Visible         =   0   'False
      End
      Begin VB.Menu mOMenu 
         Caption         =   ""
         Index           =   6
         Visible         =   0   'False
      End
      Begin VB.Menu mOMenu 
         Caption         =   "-"
         Index           =   7
         Visible         =   0   'False
      End
      Begin VB.Menu mOMenu 
         Caption         =   ""
         Index           =   8
         Visible         =   0   'False
      End
   End
   Begin VB.Menu mI 
      Caption         =   "mI"
      Visible         =   0   'False
      Begin VB.Menu mIMenu 
         Caption         =   ""
         Index           =   0
      End
      Begin VB.Menu mIMenu 
         Caption         =   "-"
         Index           =   1
      End
      Begin VB.Menu mIMenu 
         Caption         =   ""
         Enabled         =   0   'False
         Index           =   2
         Visible         =   0   'False
      End
      Begin VB.Menu mIMenu 
         Caption         =   ""
         Enabled         =   0   'False
         Index           =   3
      End
      Begin VB.Menu mIMenu 
         Caption         =   ""
         Enabled         =   0   'False
         Index           =   4
      End
      Begin VB.Menu mIMenu 
         Caption         =   "-"
         Index           =   5
      End
      Begin VB.Menu mIMenu 
         Caption         =   ""
         Index           =   6
      End
      Begin VB.Menu mIMenu 
         Caption         =   "-"
         Index           =   7
      End
      Begin VB.Menu mIMenu 
         Caption         =   ""
         Index           =   8
      End
      Begin VB.Menu mIMenu 
         Caption         =   "-"
         Index           =   9
      End
      Begin VB.Menu mIMenu 
         Caption         =   ""
         Index           =   10
      End
   End
End
Attribute VB_Name = "fMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

' Copyright (C) 2002-2004 Jan Vorel
' This program is free software; you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation; either version 2 of the License, or
' (at your option) any later version.

' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
' GNU General Public License for more details.

' You should have received a copy of the GNU General Public License
' along with this program; if not, write to the Free Software
' Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

' If you have any questions, suggestions or bug reports about this product,
' contact me: info@ctuser.net; Do not contact me about general B.A.S.I.C.
' language or A.P.I. issues











Option Explicit
Option Base 0

Private Type SHELLEXECUTEINFO
  cbSize As Long
  fMask As Long
  hwnd As Long
  lpVerb As String
  lpFile As String
  lpParameters As String
  lpDirectory As String
  nShow As Long
  hInstApp As Long
  lpIDList As Long
  lpClass As String
  hkeyClass As Long
  dwHotKey As Long
  hIcon As Long
  hProcess As Long
  End Type
Private Declare Function ShellExecuteEx Lib "shell32" Alias "ShellExecuteExA" (SEI As SHELLEXECUTEINFO) As Long

Private Declare Function GetTickCount Lib "kernel32" () As Long

'Private Const cINICacheSize As Long = 1024&
Private Const cByte0 As Byte = 0
Private Const cByte1 As Byte = 1
Private Const cByte4 As Byte = 4
Private Const QTaskIniString As String = "QTask3e"
Private Declare Function SendMessageA Lib "user32" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
'Private Declare Function GetWindowLongA Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function GetWindowsDirectoryA Lib "kernel32" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function GetSystemDirectoryA Lib "kernel32" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private xWinDir As String
Private xSpLeft As Long
Private xSpTop As Long
Private xSpMenu As Long
Private xSpButton As Long
Private xAutoStartDir As String

Dim xAutoQuitTime As Long

Dim xUnLock As Boolean
Private Const lWidth As Long = 4&
Private Const sWidth As Long = 18&

Private Type ProcessEntry32
  dwSize As Long
  cntUsage As Long
  th32ProcessID As Long
  th32DefaultHeapID As Long
  th32ModuleID As Long
  cntThreads As Long
  th32ParentProcessID As Long
  pcPriClassBase As Long
  dwFlags As Long
  szExeFile As String * 260&
  End Type
Private Type MemoryStatus
  dwLength As Long
  dwMemoryLoad As Long
  dwTotalPhys As Long
  dwAvailPhys As Long
  dwTotalPageFile As Long
  dwAvailPageFile As Long
  dwTotalVirtual As Long
  dwAvailVirtual As Long
  End Type

Private Type uSTSysTrayMainIcon
  cbSize As Long
  hwnd As Long
  uId As Long
  uFlags As Long
  uCallBackMessage As Long
  hIcon As Long
  szTip As String * 64&
  End Type
Dim SysTrayIcon As uSTSysTrayMainIcon

Private Declare Function RegOpenKeyExA Lib "advapi32.dll" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Private Declare Function RegEnumKeyA Lib "advapi32.dll" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, ByVal cbName As Long) As Long
Private Declare Function RegCreateKeyExA Lib "advapi32.dll" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, lpSecurityAttributes As Any, phkResult As Long, lpdwDisposition As Long) As Long
Private Declare Function RegEnumValueA Lib "advapi32.dll" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, lpcbValueName As Long, lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Declare Function RegQueryValueExA Lib "advapi32.dll" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Declare Function RegSetValueExA Lib "advapi32.dll" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Declare Function RegDeleteValueA Lib "advapi32.dll" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Private Declare Function RegDeleteKeyA Lib "advapi32.dll" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
Private Declare Function RegFlushKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, ByVal dwIdProc As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hnd As Long) As Boolean
Private Declare Function Process32First Lib "kernel32" (ByVal hndl As Long, ByRef pstru As ProcessEntry32) As Boolean
Private Declare Function Process32Next Lib "kernel32" (ByVal hndl As Long, ByRef pstru As ProcessEntry32) As Boolean
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessID As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Sub GlobalMemoryStatus Lib "kernel32" (lpBuffer As MemoryStatus)
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function Shell_NotifyIconA Lib "shell32.dll" (ByVal dwMessage As Long, lpData As uSTSysTrayMainIcon) As Long
Private Declare Function SHRunDialog Lib "shell32" Alias "#61" (ByVal hOwner As Long, ByVal Unknown1 As Long, ByVal Unknown2 As Long, ByVal szTitle As String, ByVal szPrompt As String, ByVal uFlags As Long) As Long
Private Declare Function SHShutDownDialog Lib "shell32" Alias "#60" (ByVal hwnd As Long) As Long
Private Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
'Private Declare Function SetWindowLongA Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long

Private Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As Long, ByVal id As Long, ByVal fsModifiers As Long, ByVal vk As Long) As Long
Private Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As Long, ByVal id As Long) As Long

Private Const MaxLog As Long = 9999&
Private Const MaxArray As Long = 32767&
Private Const NoListIndex As Long = -1&

Dim xKeyNeedRefresh As Long
Dim lHwnd As Long

'Dim MemLong As Long
Dim vBool(5) As Boolean
'4 wantsminimize
'5 canescape

'Dim xOldTemp As String
Dim xDisplayMode As Long
Dim xCurrentIcon As Long
Dim xBlockCountsCur As Long
Dim xInitSkipper As Boolean

Dim xTask(MaxArray - 1&) As String
Dim xTaskMode(MaxArray - 1&) As Byte
Dim xTaskBlocks(MaxArray - 1&) As Integer
Dim xTaskCount As Long

Dim xNew(MaxArray - 1&) As String
Dim xNewBlocks(MaxArray - 1&) As Integer
Dim xNewCount As Long
Dim xNewCurrent As Long

Private Const xBurstBlockCount As Long = 16&
Dim xCurrent(MaxArray - 1&) As String
Dim xCurrentBurstBlock(MaxArray - 1&) As Byte
Dim xCurrentID(MaxArray - 1&) As Long
Dim xCurrentBlocks(MaxArray - 1&) As Integer
Dim xCurrentCount As Long

Private Const xKeyMax As Long = 1024&
Dim xKey(xKeyMax - 1&) As String
Dim xKeyMode(xKeyMax - 1&) As Byte
Dim xKeyValue(xKeyMax - 1&) As String
Dim xKeyCaption(xKeyMax - 1&) As String
Dim xKeyPreview(xKeyMax - 1&) As String
Dim xKeyUsed(xKeyMax - 1&) As Byte ' String
Dim xKeyCount As Long

Dim xKeyOld(xKeyMax - 1&) As String
Dim xKeyOldCount As Long

Dim xTemp(MaxArray - 1&) As String
Dim xTempBlocks(MaxArray - 1&) As Integer
Dim xTempCount As Long

Dim xLogTaskCount As Long
Dim xOldFreeMem As Long
Dim xMemToFreeUp As Long
Dim xMemFreeBelow As Long
Dim xFreeingCounter As Long
Dim xCancelFreeing As Boolean
Dim xGlobalMem As Long
Dim xTrayIconMode As Boolean
Dim xTrayIconCounter As Long

Private Function xRefresh() As Long
Static xType1 As ProcessEntry32
Static xChar1 As String
Static xLong1 As Long
Static xLong2 As Long
Dim xLong3 As Long
Dim xLong4 As Long
Dim xLong5 As Long
Dim xLong6 As Long

Static xBool1 As Boolean
Dim xBool2 As Boolean
Dim xBool3 As Boolean
Dim xBool4 As Boolean

Static xCurrentRem(MaxArray - 1) As Byte
Dim AllreadyKilled As Long

xType1.dwSize = Len(xType1)
xLong1 = CreateToolhelp32Snapshot(2, 0)
xBool1 = Process32First(xLong1, xType1)

xRefresh = 0
For xLong2 = 0 To xCurrentCount - 1
  xCurrentRem(xLong2) = 1
  Next
xNewCurrent = 0

Do
  If xBool1 = False Then Exit Do
  xChar1 = Trim(xType1.szExeFile)
  xChar1 = LCase(Trim(Left(xChar1, InStr(xChar1 + vbNullChar, vbNullChar) - 1)))
  
  AllreadyKilled = 0
  xBool2 = False
  For xLong2 = 0 To xTaskCount - 1
    If xTask(xLong2) = xChar1 Then
      If Not xTaskMode(xLong2) = cByte1 Then
        xRefresh = 3
        TerminateTask xChar1, xType1.th32ProcessID
        xBool4 = True
        If Not xTaskBlocks(xLong2) = MaxLog Then
          xTaskBlocks(xLong2) = xTaskBlocks(xLong2) + 1
          If xDisplayMode = 2 Then
            sView.List(xLong2) = Int2Ext(xTask(xLong2), xTaskBlocks(xLong2))
            xBool3 = True
            End If
          End If
        End If
      AllreadyKilled = xTaskBlocks(xLong2)
      xBool2 = True
      Exit For
      End If
    Next
  
  If Not xBool2 Then
'    Stop
    For xLong2 = 0& To xTempCount - 1&
      If xTemp(xLong2) = xChar1 Then
        AllreadyKilled = xTempBlocks(xLong2)
        If xRefresh = 0 Then
          xRefresh = 1
          End If
        xBool2 = True
        End If
      Next
    End If
  
  If Not xBool2 Then
    xNewCurrent = xNewCurrent + 1
    If xRefresh < 2 Then xRefresh = 2
    For xLong2 = 0 To xNewCount - 1
      If xNew(xLong2) = xChar1 Then
        xBool2 = True
        If vBool(0) Then
          If Not xNewBlocks(xLong2) = MaxLog Then
            xNewBlocks(xLong2) = xNewBlocks(xLong2) + 1
            End If
          If xDisplayMode = 0 Then
            lView.List(xLong2) = Int2Ext(xNew(xLong2), xNewBlocks(xLong2))
            xBool3 = True
            End If
          End If
        AllreadyKilled = xNewBlocks(xLong2)
        Exit For
        End If
      Next
    If Not (xBool2 Or xNewCount = MaxArray) Then
      xNew(xNewCount) = xChar1
      If AllreadyKilled = 0 Then
        For xLong2 = 0 To xCurrentCount - 1
          If xCurrent(xLong2) = xChar1 Then
            AllreadyKilled = xCurrentBlocks(xLong2)
            Exit For
            End If
          Next
        End If
      If vBool(0) Then
        xNewBlocks(xNewCount) = AllreadyKilled + 1
        Else
        xNewBlocks(xNewCount) = AllreadyKilled + 0
        End If
      If xDisplayMode = 0 Then
        lView.AddItem Int2Ext(xChar1, xNewBlocks(xNewCount))
        If lView.SelCount = 0 Then
          lView.Selected(xNewCount) = True
          End If
        End If
      xNewCount = xNewCount + 1
      xLong5 = xNewCount
      xLong4 = 1
      End If
    If vBool(0) Then
      TerminateTask xChar1, xType1.th32ProcessID
      End If
    End If


  xBool2 = False
  For xLong2 = 0 To xCurrentCount - 1
    If xCurrentID(xLong2) = xType1.th32ProcessID Then
      xCurrentRem(xLong2) = 0
      If xBool4 Then
        If xLong2 + 1 > xLong6 Then xLong6 = xLong2 + 1
        xBool4 = False
        End If
      xBool2 = True
      Exit For
      End If
    Next
  If Not (xBool2 Or xCurrentCount = MaxArray) Then
    If xDisplayMode = 1 Then lView.AddItem Int2Ext(xChar1, AllreadyKilled)
    xCurrent(xCurrentCount) = xChar1
    xCurrentID(xCurrentCount) = xType1.th32ProcessID
    xCurrentRem(xCurrentCount) = 0
    xCurrentBlocks(xCurrentCount) = AllreadyKilled
    xCurrentBurstBlock(xCurrentCount) = 0
    xCurrentCount = xCurrentCount + 1
    If xBool4 Then
      xLong6 = xCurrentCount
      End If
    xBool3 = True
    End If
  xBool1 = Process32Next(xLong1, xType1)
  Loop
CloseHandle xLong1

For xLong1 = xCurrentCount - 1 To 0 Step -1
  If xCurrentRem(xLong1) = 1 Then
    If xDisplayMode = 1 Then lView.RemoveItem xLong1
    For xLong2 = xLong1 To xCurrentCount - 2
      xCurrent(xLong2) = xCurrent(xLong2 + 1)
      xCurrentID(xLong2) = xCurrentID(xLong2 + 1)
      xCurrentBlocks(xLong2) = xCurrentBlocks(xLong2 + 1)
      xCurrentBurstBlock(xLong2) = xCurrentBurstBlock(xLong2 + 1)
      Next
    If xLong6 - 1 > xLong1 Then
      xLong6 = xLong6 - 1
      End If
    xCurrentCount = xCurrentCount - 1
    xBool3 = True
    End If
  Next



For xLong1 = 0 To xCurrentCount - 1
  If Not xCurrentBurstBlock(xLong1) = 0 Then
    Do
      For xLong2 = 0 To xTaskCount - 1
        If xTask(xLong2) = xCurrent(xLong1) And xTaskMode(xLong2) = cByte0 Then
          xCurrentBurstBlock(xLong1) = 0
          Exit Do
          End If
        Next
      If vBool(0) Then
        For xLong2 = 0 To xNewCount - 1
          If xNew(xLong2) = xCurrent(xLong1) Then
            xCurrentBurstBlock(xLong1) = 0
            Exit Do
            End If
          Next
        End If
      For xLong2 = 0 To xTempCount - 1
        If xTemp(xLong2) = xCurrent(xLong1) Then
          xCurrentBurstBlock(xLong1) = 0
          Exit Do
          End If
        Next
        
      xRefresh = 3
      xCurrentBurstBlock(xLong1) = xCurrentBurstBlock(xLong1) - 1
      If xCurrentBurstBlock(xLong1) = 0 Then
        xLong4 = 2
        xLong5 = xLong1 + 1
        Else
        If xCurrentBurstBlock(xLong1) Mod 2 = 0 Then
          TerminateTask xCurrent(xLong1), xCurrentID(xLong1)
          For xLong2 = 0 To xTaskCount - 1
            If xTask(xLong2) = xCurrent(xLong1) Then
              If Not xTaskBlocks(xLong2) = MaxLog Then
                xTaskBlocks(xLong2) = xTaskBlocks(xLong2) + 1
                If xDisplayMode = 2 Then
                  xLong3 = sView.ListIndex
                  sView.List(xLong2) = Int2Ext(xTask(xLong2), xTaskBlocks(xLong2))
                  sView.ListIndex = xLong3
                  End If
                End If
              End If
            Next
          For xLong2 = 0 To xNewCount - 1
            If xNew(xLong2) = xCurrent(xLong1) Then
              If Not xNewBlocks(xLong2) = MaxLog Then
                xNewBlocks(xLong2) = xNewBlocks(xLong2) + 1
                If xDisplayMode = 0 Then lView.List(xLong2) = Int2Ext(xNew(xLong2), xNewBlocks(xLong2))
                End If
              End If
            Next
          For xLong2 = 0 To xTempCount - 1
            If xTemp(xLong2) = xCurrent(xLong1) Then
              If Not xTempBlocks(xLong2) = MaxLog Then
                xTempBlocks(xLong2) = xTempBlocks(xLong2) + 1
                If xDisplayMode = 5 Then lView.List(xLong2) = Int2Ext(xTemp(xLong2), xTempBlocks(xLong2))
                End If
              End If
            Next
          End If
        End If
      Exit Do
      Loop
    End If
  Next


If Not xLong6 = 0 Then
  If Not xBlockCountsCur = 6 Then
    xBlockCountsCur = xBlockCountsCur + 1
    End If
  If xBlockCountsCur = 5 Then
    xLong4 = 2
    xLong5 = xLong6
    End If
  Else
  xBlockCountsCur = 0
  End If



If Not xLong4 = 0 Then
  ctMenuA1.CurrentItem = xLong4 - 1
  If Not xLong5 = 0 Then
    For xLong1 = 0 To lView.ListCount - 1
      lView.Selected(xLong1) = False
      Next
    lView.Selected(xLong5 - 1) = True
    End If
  UpdateTemp
  If vBool(1) Or xInitSkipper Then
    If Me.WindowState = 1 Or xInitSkipper Or xTrayIconMode Then
      vBool(4) = True
      If xTrayIconMode Then
        xTrayIconMode = False
        Me.Visible = True
        xAutoQuitTime = 0
        Else
        Me.WindowState = 0
        End If
      Me.Show
      Call SetWindowPos(Me.hwnd, -1, -1, -1, 0, 0, 3)
      End If
    End If
  End If

If xBool3 Then SetWidth ' 1
End Function

Private Function Int2Ext(ByVal xChar1 As String, Optional ByVal Blocks As Long, Optional ByVal ReplaceString As String) As String
Static xLong1 As Long

'Do While InStr(xChar1, "\") > 0
'  Int2Ext = Int2Ext + "\" + Left(xChar1, InStr(xChar1, "\") - 1)
'  xChar1 = Mid(xChar1, InStr(xChar1, "\") + 1)
'  Loop
Do
  xLong1 = InStr(xChar1, "\")
  If xLong1 = 0 Then Exit Do
  Int2Ext = Int2Ext + "\" + Left(xChar1, xLong1 - 1)
  xChar1 = Mid(xChar1, xLong1 + 1)
  Loop

If Trim(xChar1) = "" Then xChar1 = LoadResString(20)
If Not ReplaceString = "" Then
  xChar1 = Replace(ReplaceString, "$", xChar1)
  End If

If Not xDisplayMode = 2 Then xLong1 = 2
If Blocks > 0 Then
  If Len(xChar1) < 24 + xLong1 Then
    xChar1 = Left(xChar1 + Space(24 + xLong1), 24 + xLong1)
    Else
    xChar1 = xChar1 + "    "
    End If
    xChar1 = xChar1 + Right(Space(6) + "(" + Trim(Str(Blocks)) + ")" + "  ", 8)
  Else
  If Len(xChar1) < 29 + xLong1 Then
    xChar1 = Left(xChar1 + Space(32 + xLong1), 32 + xLong1)
    Else
    xChar1 = xChar1 + "    "
    End If
  End If

Int2Ext = xChar1 + Mid(Int2Ext, 2)
End Function

Private Sub ctMenuA1_ItemClick(ByVal Index As Long)
Dim xLong1 As Long
Dim xLong2 As Long
Dim xLong3 As Long
Dim xChar1 As String
Dim xBool1 As Boolean

xAutoQuitTime = 0

vBool(4) = False
If (vBool(0) Or Not xTempCount = 0) And Index > 2 Then
  If Index = 3 Then
    Index = 5
    Else
    Index = Index - 1
    End If
  End If
If xDisplayMode = Index Then Exit Sub

lView.Visible = (Index = 0 Or Index = 1 Or Index = 5)
lView.Clear
sView.Visible = (Index = 2 Or Index = 3)
sView.Clear
iView.Visible = (Index = 4)
If (xDisplayMode = 0 And vBool(0) Or xDisplayMode = 3) And Not (Index = 0 And vBool(0) Or Index = 3) Then
  eButton(4).Visible = False
  mOMenu(7).Visible = False
  mOMenu(8).Visible = False
  End If

'If xDisplayMode = 4 Then
'  eButton(2).Visible = True
'  mOMenu(3).Visible = True
'  mOMenu(4).Visible = True
'  End If

xBool1 = (Index = 0 Or Index = 1 Or Index = 2 And Not vBool(0) Or Index = 3 Or Index = 5)
eButton(3).Visible = xBool1
mOMenu(5).Visible = xBool1
mOMenu(6).Visible = xBool1
xDisplayMode = Index

Select Case Index
  Case 0
    If xNewCount = 0 Then
      Call SendMessageA(lView.hwnd, 404, 0, 0)
      Else
      For xLong1 = 0 To xNewCount - 1
        xChar1 = Int2Ext(xNew(xLong1), xNewBlocks(xLong1))
        xLong2 = Len(xChar1)
        If xLong2 > xLong3 Then xLong3 = xLong2
        lView.AddItem xChar1
        Next
      lView.Selected(xNewCount - 1) = True
      Call SendMessageA(lView.hwnd, 404, lWidth + xLong3 * 7, 0)
      End If
    eButton(0).Caption = LoadResString(220)
    eButton(1).Caption = LoadResString(221)
    eButton(2).Caption = LoadResString(222)
    eButton(3).Caption = LoadResString(223)
    mOMenu(0).Caption = LoadResString(220)
    mOMenu(2).Caption = LoadResString(221)
    mOMenu(4).Caption = LoadResString(222)
    mOMenu(6).Caption = LoadResString(223)
    
    If vBool(0) Then
      eButton(4).Caption = LoadResString(224)
      eButton(4).Visible = True
      mOMenu(8).Caption = LoadResString(224)
      mOMenu(7).Visible = True
      mOMenu(8).Visible = True
      End If
  Case 1
    For xLong1 = 0 To xCurrentCount - 1
      xChar1 = Int2Ext(xCurrent(xLong1), xCurrentBlocks(xLong1))
      xLong2 = Len(xChar1)
      If xLong2 > xLong3 Then xLong3 = xLong2
      lView.AddItem xChar1
      Next
    If Not xCurrentCount = 0 Then
      lView.Selected(xCurrentCount - 1) = True
      End If
    Call SendMessageA(lView.hwnd, 404, lWidth + xLong3 * 7, 0)
    eButton(0).Caption = LoadResString(230)
    eButton(1).Caption = LoadResString(231)
    eButton(2).Caption = LoadResString(232)
    eButton(3).Caption = LoadResString(233)
    mOMenu(0).Caption = LoadResString(230)
    mOMenu(2).Caption = LoadResString(231)
    mOMenu(4).Caption = LoadResString(232)
    mOMenu(6).Caption = LoadResString(233)
    xRefresh
  Case 2
    If xTaskCount = 0 Then
      Call SendMessageA(sView.hwnd, 404, 0, 0)
      Else
      For xLong1 = 0 To xTaskCount - 1
        xChar1 = Int2Ext(xTask(xLong1), xTaskBlocks(xLong1))
        xLong2 = Len(xChar1)
        If xLong2 > xLong3 Then xLong3 = xLong2
        sView.AddItem xChar1
        sView.Selected(xLong1) = (xTaskMode(xLong1) = cByte1)
        Next
      Call SendMessageA(sView.hwnd, 404, sWidth + xLong3 * 7, 0)
      End If
    eButton(0).Caption = LoadResString(220)
    eButton(1).Caption = LoadResString(221)
    eButton(2).Caption = LoadResString(222)
    eButton(3).Caption = LoadResString(223)
    mOMenu(0).Caption = LoadResString(220)
    mOMenu(2).Caption = LoadResString(221)
    mOMenu(4).Caption = LoadResString(222)
    mOMenu(6).Caption = LoadResString(223)
  Case 3
    eButton(0).Caption = LoadResString(250)
    eButton(1).Caption = LoadResString(251)
    eButton(2).Caption = LoadResString(252)
    eButton(3).Caption = LoadResString(253)
    eButton(4).Caption = LoadResString(254)
    eButton(4).Visible = True
    mOMenu(0).Caption = LoadResString(250)
    mOMenu(2).Caption = LoadResString(251)
    mOMenu(4).Caption = LoadResString(252)
    mOMenu(6).Caption = LoadResString(253)
    mOMenu(8).Caption = LoadResString(254)
    mOMenu(7).Visible = True
    mOMenu(8).Visible = True
    RefreshKeys
  Case 4
    eButton(0).Caption = LoadResString(240)
    If xIsFreeing Then
      eButton(1).Caption = LoadResString(242)
      Else
      eButton(1).Caption = LoadResString(241)
      End If
    eButton(2).Caption = LoadResString(245)
    eLabel(4).Caption = ""
'    eButton(2).Visible = False
'    mOMenu(3).Visible = False
'    mOMenu(4).Visible = False
  Case 5
    If xTempCount = 0 Then
      Call SendMessageA(lView.hwnd, 404, 0, 0)
      Else
      For xLong1 = 0 To xTempCount - 1
        xChar1 = Int2Ext(xTemp(xLong1), xTempBlocks(xLong1))
        xLong2 = Len(xChar1)
        If xLong2 > xLong3 Then xLong3 = xLong2
        lView.AddItem xChar1
        Next
      Call SendMessageA(lView.hwnd, 404, lWidth + xLong3 * 7, 0)
      End If
    eButton(0).Caption = LoadResString(220)
    eButton(1).Caption = LoadResString(221)
    eButton(2).Caption = LoadResString(222)
    eButton(3).Caption = LoadResString(223)
    mOMenu(0).Caption = LoadResString(220)
    mOMenu(2).Caption = LoadResString(221)
    mOMenu(4).Caption = LoadResString(222)
    mOMenu(6).Caption = LoadResString(223)
  End Select
Form_Resize
End Sub

Private Sub eButton_Click(Index As Integer)
Dim xChar1 As String
Dim xChar2 As String
'Dim xChar3 As String
Dim xLong1 As Long
Dim xLong2 As Long
Dim xLong3 As Long
'Dim xLong4 As Long
'Dim xLong5 As Long

xAutoQuitTime = 0
xUnLock = True
Select Case xDisplayMode * 5 + Index
  Case 0, 1 'accept new
    '0 > AddToList True
    '1 > AddToList False
    If Not xNewCount = 0 Then
      For xLong1 = xNewCount - 1 To 0 Step -1
        If lView.Selected(xLong1) And Not xTaskCount = MaxArray Then
          xChar1 = Int2Ext(xNew(xLong1))
          For xLong2 = 0 To xTaskCount - 1
            If xChar1 < Int2Ext(xTask(xLong2)) Then Exit For
            Next
          For xLong3 = xTaskCount To xLong2 + 1 Step -1
            xTask(xLong3) = xTask(xLong3 - 1)
            xTaskBlocks(xLong3) = xTaskBlocks(xLong3 - 1)
            xTaskMode(xLong3) = xTaskMode(xLong3 - 1)
            Next
          xTaskCount = xTaskCount + 1
          xTask(xLong2) = xNew(xLong1)
          xTaskBlocks(xLong2) = xNewBlocks(xLong1)
          xTaskMode(xLong2) = cByte1 - CByte(Index)
          For xLong2 = xLong1 To xNewCount - 2
            xNew(xLong2) = xNew(xLong2 + 1)
            xNewBlocks(xLong2) = xNewBlocks(xLong2 + 1)
            Next
          xNewCount = xNewCount - 1
          lView.RemoveItem xLong1
          SetWidth
          End If
        Next
      If xNewCount = 0 Then
        CheckMinimize
        Else
        If lView.SelCount = 0 Then
          lView.Selected(xNewCount - 1) = True
          End If
        End If
      UpdateTemp
      End If
  Case 2 'remove new
    For xLong1 = xNewCount - 1 To 0 Step -1
      If lView.Selected(xLong1) Then
        For xLong2 = xLong1 To xNewCount - 2
          xNew(xLong2) = xNew(xLong2 + 1)
          xNewBlocks(xLong2) = xNewBlocks(xLong2 + 1)
          Next
        xNewCount = xNewCount - 1
        lView.RemoveItem xLong1
        End If
      Next
    If xNewCount = 0 Then
      CheckMinimize
      Else
      If lView.SelCount = 0 Then
        lView.Selected(xNewCount - 1) = True
        End If
      SetWidth
      End If
    UpdateTemp
  Case 3 'removeall
    xNewCount = 0
    Erase xNew
    Erase xNewBlocks
    lView.Clear
    CheckMinimize
    SetWidth
    UpdateTemp
  Case 4
    For xLong1 = 0 To xNewCount - 1
      If lView.Selected(xLong1) Then
        xChar1 = xNew(xLong1)
        For xLong2 = 0 To xTempCount - 1
          If xTemp(xLong1) = xChar1 Then
            xChar1 = ""
            Exit For
            End If
          Next
        If Not (xChar1 = "" Or xTempCount = MaxArray) Then
          xLong2 = 0
          xChar2 = Int2Ext(xNew(xLong1))
          Do
            If xLong2 = xTempCount Then Exit Do
            If xChar1 < Int2Ext(xTemp(xLong2)) Then Exit Do
            xLong2 = xLong2 + 1
            Loop
          For xLong3 = xTempCount To xLong2 + 1 Step -1
            xTemp(xLong3) = xTemp(xLong3 - 1)
            xTempBlocks(xLong3) = xTempBlocks(xLong3 - 1)
            Next
          xTempCount = xTempCount + 1
          xTemp(xLong2) = xNew(xLong1)
          xTempBlocks(xLong2) = xNewBlocks(xLong1)
          For xLong2 = xLong1 To xNewCount - 2
            xNew(xLong2) = xNew(xLong2 + 1)
            xNewBlocks(xLong2) = xNewBlocks(xLong2 + 1)
            Next
          xNewCount = xNewCount - 1
          lView.RemoveItem xLong1
          SetWidth
          End If
        End If
      Next
    UpdateTemp
  Case 5 'killtask
    For xLong1 = 0 To xCurrentCount - 1
      If lView.Selected(xLong1) Then
        xChar1 = xCurrent(xLong1)
        xCurrentBurstBlock(xLong1) = xBurstBlockCount
        TerminateTask xChar1, xCurrentID(xLong1)
        For xLong2 = 0 To xTaskCount - 1
          If xTask(xLong2) = xChar1 Then
            If Not xTaskBlocks(xLong2) = MaxLog Then
              xTaskBlocks(xLong2) = xTaskBlocks(xLong2) + 1
              End If
            End If
          Next
        For xLong2 = 0 To xNewCount - 1
          If xNew(xLong2) = xChar1 Then
            If Not xNewBlocks(xLong2) = MaxLog Then
              xNewBlocks(xLong2) = xNewBlocks(xLong2) + 1
              End If
            End If
          Next
        For xLong2 = 0 To xTempCount - 1
          If xTemp(xLong2) = xChar1 Then
            If Not xTempBlocks(xLong2) = MaxLog Then
              xTempBlocks(xLong2) = xTempBlocks(xLong2) + 1
              End If
            End If
          Next
        End If
      Next
  Case 6 'FindTask
    xLong1 = lView.ListIndex
    If Not xLong1 = NoListIndex Then
      xChar1 = xCurrent(xLong1)
      Do
        For xLong1 = 0 To xTaskCount - 1
          If xChar1 = xTask(xLong1) Then
            ctMenuA1.CurrentItem = 2
            sView.ListIndex = xLong1
            Exit Do
            End If
          Next
        For xLong1 = 0 To xNewCount - 1
          If xChar1 = xNew(xLong1) Then
            ctMenuA1.CurrentItem = 0
            lView.Selected(xLong1) = True
            Exit Do
            End If
          Next
        For xLong1 = 0 To xTempCount - 1
          If xChar1 = xTemp(xLong1) Then
            ctMenuA1.CurrentItem = 5
            lView.Selected(xLong1) = True
            Exit Do
            End If
          Next
        Exit Do
        Loop
      End If
  Case 7 'launch any task
    SHRunDialog Me.hwnd, 0, 0, LoadResString(160), LoadResString(161), 0
  Case 8 'shut down
    SHShutDownDialog Me.hwnd
  Case 10, 11 ' accept/denie known
    xLong1 = sView.ListIndex
    If Not xLong1 = NoListIndex Then
      xTaskMode(xLong1) = cByte1 - CByte(Index)
      sView.Selected(xLong1) = (xTaskMode(xLong1) = cByte1)
      End If
  Case 12 'removeknown
    xLong2 = sView.ListIndex
    If Not xTaskCount = 0 And Not xLong2 = NoListIndex Then
      For xLong1 = xLong2 To xTaskCount - 2
        xTask(xLong1) = xTask(xLong1 + 1)
        xTaskMode(xLong1) = xTaskMode(xLong1 + 1)
        xTaskBlocks(xLong1) = xTaskBlocks(xLong1 + 1)
        Next
      xTaskCount = xTaskCount - 1
      sView.RemoveItem xLong2
      SetWidth
      End If
  Case 13 'removeallknown
    If MsgBox(LoadResString(155), vbOKCancel + vbExclamation, LoadResString(150)) = vbOK Then
      xTaskCount = 0
      Erase xTask
      Erase xTaskBlocks
      Erase xTaskMode
      sView.Clear
      SetWidth
      End If
  Case 15, 16 'enable/disable autostart programmes
    xLong1 = sView.ListIndex
    If Not xLong1 = -1 Then
      Select Case xKeyMode(xLong1)
        Case 0, 1
          '''If Not xKeyUsed(xLong1) = (Index = 0) Then
          If xKeyUsed(xLong1) = Index Then
            If xKeyUsed(xLong1) = cByte1 Then
              xChar1 = xKey(xLong1) & "-"
              Else
              xChar1 = Left(xKey(xLong1), Len(xKey(xLong1)) - 1)
              End If
            If RegCreateKeyExA(&H80000001 + xKeyMode(xLong1), xChar1, 0&, "", 0, 983103, ByVal 0&, xLong2, xLong3) = 0& Then
              Call RegSetValueExA(xLong2, xKeyValue(xLong1), 0&, 1, ByVal xKeyPreview(xLong1), Len(xKeyPreview(xLong1)))
              Call RegFlushKey(xLong2)
              Call RegCloseKey(xLong2)
              If RegOpenKeyExA(&H80000001 + xKeyMode(xLong1), xKey(xLong1), 0, 983103, xLong2) = &O0 Then
                Call RegDeleteValueA(xLong2, xKeyValue(xLong1))
                Call RegFlushKey(xLong2)
                Call RegCloseKey(xLong2)
                End If
              End If
            DoEvents
            RefreshKeys True
            xKeyNeedRefresh = 0
            End If
        Case 2 ''' Autostart Link
          Call MsgBox(Replace(LoadResString(177), "|", vbCr), , LoadResString(175))
        Case 3 ''' INI
        
          '3 winini, run, 4 winini, load, 5 systemini, scrsaver, ...
'          Call MsgBox(Replace(LoadResString(178), "|", vbCr), , LoadResString(175))
          'If ChangeIniSettings(xLong1, 1& - CLng(Index)) Then
          Call ChangeIniSettings(xLong1, 1& - CLng(Index))
            RefreshKeys True
            xKeyNeedRefresh = 0
            'End If
        Case 16, 17
          Call MsgBox(Replace(LoadResString(176), "|", vbCr), , LoadResString(175))
          DoEvents
          sView.Refresh
          DoEvents
        End Select
      End If
  Case 17, 19 'details
    xLong1 = sView.ListIndex
    If Not xLong1 = -1 Then
      Select Case xKeyMode(xLong1)
        Case 0, 1
          xChar1 = LoadResString(185) & vbCr & Space(3) & LoadResString(186 + xKeyMode(xLong1)) & vbCr & Space(6)
          If xKeyUsed(xLong1) = cByte1 Then
            xChar1 = xChar1 & xKey(xLong1)
            Else
            xChar1 = xChar1 & Left(xKey(xLong1), Len(xKey(xLong1)) - 1)
            End If
          xChar1 = xChar1 & vbCr & Space(9) & xKeyValue(xLong1) & vbCr + _
                   Space(12) & xKeyPreview(xLong1)
          If Index = 2 Then
            Call MsgBox(xChar1, vbInformation, LoadResString(180))
            Else
            If MsgBox(Replace(Replace(LoadResString(171), "$", xChar1), "|", vbCr), vbCritical + vbOKCancel, LoadResString(170)) = vbOK Then
              If RegOpenKeyExA(&H80000001 + xKeyMode(xLong1), xKey(xLong1), 0, 983103, xLong2) = &O0 Then
                RegDeleteValueA xLong2, xKeyValue(xLong1)
                Call RegFlushKey(xLong2)
                Call RegCloseKey(xLong2)
                RefreshKeys True
                xKeyNeedRefresh = 0
                End If
              End If
            End If
        Case 2 'lnkautostart
          If Index = 2 Then
'            Stop
            If LCase(Right(xKeyValue(xLong1), 4&)) = ".lnk" Then
              ShowFileProperties (xAutoStartDir & xKeyValue(xLong1))
              'Stop
              End If
            Else
            xChar1 = xAutoStartDir & xKeyValue(xLong1)
            If MsgBox(Replace(Replace(LoadResString(173), "$", xChar1), "|", vbCr), vbCritical + vbOKCancel, LoadResString(170)) = vbOK Then
              Kill xChar1
              RefreshKeys True
              xKeyNeedRefresh = 0
              End If
            End If
        Case 3 'iniautostart
'          Stop
          If Index = 4 Then
            xChar1 = xWinDir & xKey(xLong1) & vbCr & _
                     Space(3) & xKeyValue(xLong1) & vbCr & _
                     Space(6) & xKeyPreview(xLong1)
            If MsgBox(Replace(Replace(LoadResString(174), "$", xChar1), "|", vbCr), vbCritical + vbOKCancel, LoadResString(170)) = vbOK Then
'              Stop
              'If ChangeIniSettings(xLong1, 2) Then
              Call ChangeIniSettings(xLong1, 2&)
                RefreshKeys True
                xKeyNeedRefresh = 0&
                'End If
              End If
            End If
        Case 16, 17
          xChar1 = LoadResString(185) & vbCr & Space(3) & LoadResString(170 + xKeyMode(xLong1)) & vbCr & Space(6)
          If xKeyUsed(xLong1) = cByte1 Then
            xChar1 = xChar1 & xKey(xLong1)
            Else
            xChar1 = xChar1 & Left(xKey(xLong1), Len(xKey(xLong1)) - 1)
            End If
          If Index = 2 Then
            xChar1 = xChar1 & vbCr & Space(9) & Replace(LoadResString(181), "$", xKeyValue(xLong1))
            Else
            xChar1 = xChar1 & vbCr & Space(9) & xKeyValue(xLong1)
            End If
          If Index = 2 Then
            Call MsgBox(xChar1, vbInformation, LoadResString(180))
            Else
            If MsgBox(Replace(Replace(LoadResString(172), "$", xChar1), "|", vbCr), vbCritical + vbOKCancel, LoadResString(170)) = vbOK Then
              RegDeleteKeyA &H80000001 + xKeyMode(xLong1) - 16, xKey(xLong1) + "\" + xKeyValue(xLong1)
              RefreshKeys True
              RefreshKeys True
              xKeyNeedRefresh = 0
              End If
            End If
        End Select
      DoEvents
      sView.Refresh
      DoEvents
      End If
  Case 18 'refreshautorun
    RefreshKeys True
    xKeyNeedRefresh = 0
  Case 20 'clearlogs
    Erase xNewBlocks
    Erase xTaskBlocks
    Erase xCurrentBlocks
    Erase xTempBlocks
  Case 21 'freemem / stopfreemem
    If xIsFreeing Then
      xCancelFreeing = True
      Else
      eButtonFreeUp.Value = 1
      End If
  Case 22 'quit
    Unload Me
  Case 25, 26
      For xLong1 = xTempCount - 1 To 0 Step -1
        If lView.Selected(xLong1) And Not xTaskCount = MaxArray Then
          xChar1 = Int2Ext(xTemp(xLong1))
          For xLong2 = 0 To xTaskCount - 1
            If xChar1 < Int2Ext(xTask(xLong2)) Then Exit For
            Next
          For xLong3 = xTaskCount To xLong2 + 1 Step -1
            xTask(xLong3) = xTask(xLong3 - 1)
            xTaskBlocks(xLong3) = xTaskBlocks(xLong3 - 1)
            xTaskMode(xLong3) = xTaskMode(xLong3 - 1)
            Next
          xTaskCount = xTaskCount + 1
          xTask(xLong2) = xTemp(xLong1)
          xTaskBlocks(xLong2) = xTempBlocks(xLong1)
          xTaskMode(xLong2) = cByte1 - CByte(Index)
          For xLong2 = xLong1 To xTempCount - 2
            xTemp(xLong2) = xTemp(xLong2 + 1)
            xTempBlocks(xLong2) = xTempBlocks(xLong2 + 1)
            Next
          xTempCount = xTempCount - 1
          lView.RemoveItem xLong1
          SetWidth
          End If
        Next
      If Not xTempCount = 0 Then
        If lView.SelCount = 0 Then
          lView.Selected(xTempCount - 1) = True
          End If
        End If
      UpdateTemp
  Case 27
      For xLong1 = xTempCount - 1 To 0 Step -1
        If lView.Selected(xLong1) Then
          For xLong2 = xLong1 To xTempCount - 2
            xTemp(xLong2) = xTemp(xLong2 + 1)
            xTempBlocks(xLong2) = xTempBlocks(xLong2 + 1)
            Next
          lView.RemoveItem xLong1
          xTempCount = xTempCount - 1
          End If
        Next
      SetWidth
      UpdateTemp
  Case 28
      xTempCount = 0
      lView.Clear
      SetWidth
      Erase xTemp
      Erase xTempBlocks
      UpdateTemp
  End Select

xUnLock = False
End Sub

Private Sub eButtonFreeUp_Click()
Dim xLong1 As Long
Static xCharA1(65535) As String

mIMenu(6).Caption = LoadResString(276)
If xDisplayMode = 4 Then
  eButton(1).Caption = LoadResString(242)
  End If

xIsFreeing = True
On Error GoTo Er1
xLong1 = &H80000

For xFreeingCounter = 0 To xMemToFreeUp
  xCharA1(xFreeingCounter) = Space(xLong1)
  If xFreeingCounter Mod 4 = 0 Then DoEvents
  If xCancelFreeing Then
    Exit For
    End If
  Next

Rs1:
On Error GoTo 0
Erase xCharA1
If xInitSkipper Then Exit Sub
If Not xInitSkipper And xDisplayMode = 4 Then
  eButton(1).Caption = LoadResString(241)
  End If
xIsFreeing = False
xCancelFreeing = False
If Not xInitSkipper Then
  mIMenu(6).Caption = LoadResString(275)
  End If
Exit Sub

Er1:
Resume Rs1
End Sub

Private Sub eButtonFreeUp_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim xLong1 As Long
If xInitSkipper Then Exit Sub
xLong1 = X / Screen.TwipsPerPixelX
If xLong1 = &H201 Or xLong1 = &H203 Then
  Me.Visible = True
  xAutoQuitTime = 0
  xTrayIconMode = False
  End If
If xLong1 = &H204 Then
  PopupMenu mI, , , , mIMenu(0)
  End If
End Sub

Private Sub eButtonHide_Click()
Me.WindowState = 1
End Sub

Private Sub eCheckBox_Click(Index As Integer)
Dim xLong1 As Long
Dim xLong2 As Long
Dim xLong3 As Long
Dim xChar1 As String
Dim xBool1 As Boolean

If Not xInitSkipper Then
  Select Case Index
    Case 4
      xBool1 = eCheckBox(4).Value = 1
      RefreshKeys False, False
      If xBool1 Then
        If RegCreateKeyExA(&H80000002, "Software\Microsoft\Windows\CurrentVersion\Run", 0&, "", 0, 983103, ByVal 0&, xLong1, xLong2) = 0& Then
          xChar1 = AppBase(vbNullChar) + " /AUTORUN"
          RegSetValueExA xLong1, "QuickTask3", 0&, 1, ByVal xChar1, Len(xChar1)
          Call RegFlushKey(xLong2)
          RegCloseKey (xLong1)
          End If
        Else
        If RegOpenKeyExA(&H80000002, "Software\Microsoft\Windows\CurrentVersion\Run", 0&, 983103, xLong1) = 0& Then
          RegDeleteValueA xLong1, "QuickTask3"
          Call RegFlushKey(xLong2)
          RegCloseKey (xLong1)
          End If
        End If
      RefreshKeys (xDisplayMode = 3), True
    Case 0
      If vBool(0) Then
        xInitSkipper = True
        eCheckBox(0).Value = 0
        xInitSkipper = False
        vBool(0) = False
        mIMenu(2).Visible = False
        mIMenu(8).Checked = False
        ctMenuA1.RemoveItemExQT
        ctMenuA1.SetItem 3, LoadResString(204), 114
        ctMenuA1.SetItem 4, LoadResString(205), 115
          
        If xNewCount + xTempCount > MaxArray Then
          xTempCount = MaxArray - xNewCount
          End If
        For xLong1 = 0 To xTempCount - 1
          xNew(xNewCount + xLong1) = xTemp(xLong1)
          xNewBlocks(xNewCount + xLong1) = xTempBlocks(xLong1)
          Next
        xNewCount = xNewCount + xTempCount
        If xDisplayMode = 0 Then
          If xNewCount = 0 Then
            Call SendMessageA(lView.hwnd, 404, 0, 0)
            Else
            For xLong1 = 0 To xNewCount - 1
              xChar1 = Int2Ext(xNew(xLong1), xNewBlocks(xLong1))
              xLong2 = Len(xChar1)
              If xLong2 > xLong3 Then xLong3 = xLong2
              lView.AddItem xChar1
              Next
            lView.Selected(xNewCount - 1) = True
            Call SendMessageA(lView.hwnd, 404, lWidth + xLong3 * 7, 0)
            End If
          End If
        If xDisplayMode = 5 Then
          ctMenuA1_ItemClick 3
          End If
        Erase xTemp
        Erase xTempBlocks
        xTempCount = 0
        UpdateTemp
        Else
        xInitSkipper = True
        eCheckBox(0).Value = 0
        If xNewCurrent = 0 Then
          xChar1 = LoadResString(151)
          Else
          xChar1 = Replace(LoadResString(152), "$", Trim(Str(xNewCount)))
          End If
        If MsgBox(Replace(xChar1, "|", vbCr), vbCritical + vbOKCancel, LoadResString(150)) = vbOK Then
          eCheckBox(0).Value = 1
          vBool(0) = True
          mIMenu(2).Visible = True
          mIMenu(8).Checked = True
          ctMenuA1.AddItemExQT
          ctMenuA1.SetItem 3, LoadResString(203), 113
          ctMenuA1.SetItem 4, LoadResString(204), 114
          ctMenuA1.SetItem 5, LoadResString(205), 115
          End If
        xInitSkipper = False
        End If
    Case 3
      If Not vBool(3) = (eCheckBox(3).Value = 1) Then
        If vBool(3) Then
          vBool(3) = False
          Shell_NotifyIconA 2, SysTrayIcon
          Else
          SysTrayIcon.hIcon = Me.Icon
          SysTrayIcon.szTip = Me.Caption & vbNullChar
          Shell_NotifyIconA 0, SysTrayIcon
          vBool(3) = True
          End If
        End If
    
    Case Else
      vBool(Index) = (eCheckBox(Index).Value = 1)
    End Select
  End If
End Sub

Public Sub eRefreshTimer()
Static xLong1 As Long
Static xLong2 As Long
Static xLong3 As Long  ''
Static xChar1 As String  ''

If xInitSkipper Then Exit Sub
xLong1 = xFreeMem
If xInitSkipper Then Exit Sub
xLong2 = xRefresh

xCurrentIcon = xLong2
xLogTaskCount = xCurrentCount
If xLong1 < 0 Then
  Me.Caption = Replace(Replace(LoadResString(10&), "$", Trim(Str(xLogTaskCount))), "%", Trim(Str(-xLong1)) + "%")
  xLong2 = 140& + xLong2 + 4& * Int(-xLong1 / 34&)
  Else
  Me.Caption = Replace(Replace(LoadResString(11), "$", Trim(Str(xLogTaskCount))), "%", Trim(Str(xLong1)))
  xLong2 = 120& + xLong2 + 4& * (Int(Sqr(xLong1) / (Sqr(xGlobalMem) + 1&) * 4&))
  End If
 xOldFreeMem = xLong1
Me.Icon = LoadResPicture(xLong2, 1&)
SysTrayIcon.hIcon = Me.Icon
SysTrayIcon.szTip = Me.Caption & vbNullChar
Shell_NotifyIconA 1, SysTrayIcon

xTrayIconCounter = xTrayIconCounter + 1&
If xTrayIconCounter = 300& Then
  xTrayIconCounter = 0&
  If vBool(3) Then
    Shell_NotifyIconA 2&, SysTrayIcon
    Shell_NotifyIconA 0&, SysTrayIcon
    End If
  End If

xKeyNeedRefresh = (xKeyNeedRefresh + 1&) Mod 16&
If xKeyNeedRefresh = 15& And Not xInitSkipper Then
  RefreshKeys True
  End If



'Dim xLong1 As Long
'Dim xLong2 As Long
'Dim xChar1 As String


If xDisplayMode = 4& Then
  xLong1 = GetTickCount \ 1000&
  xLong3 = xLong1 \ 86400
  xLong1 = xLong1 - xLong3 * 86400
  
  
  'xChar1 = Trim(Str(xLong2))
  
  xLong2 = xLong1 \ 3600&
  xLong1 = xLong1 - xLong2 * 3600&
  xChar1 = Right("00" & Trim(Str(xLong2)), 2&)
  xLong2 = xLong1 \ 60&
  xLong1 = xLong1 - xLong2 * 60&
  
  xChar1 = xChar1 & ":" & Right("00" & Trim(Str(xLong2)), 2&) & ":" & Right("00" & Trim(Str(xLong1)), 2)
  
  If xLong3 = 0& Then
    xChar1 = Replace(LoadResString(208), "%", xChar1)
    Else
    xChar1 = Replace(Replace(LoadResString(209), "$", Trim(Str(xLong3))), "%", xChar1)
    End If
  eLabel(4).Caption = xChar1
  End If

If Abs(Timer * 100 - xAutoQuitTime) > 1200 And Not xAutoQuitTime = 0 Then
  Unload Me
  End If
End Sub

Private Sub Form_Load()
Dim xChar1 As String
Dim xChar2 As String
Dim xLong1 As Long
Dim xLong2 As Long
Dim xLong3 As Long


xSpLeft = ctMenuA1.Left
xSpTop = ctMenuA1.Top
xSpMenu = 2 * xSpLeft + ctMenuA1.Width
xSpButton = xSpTop + eButton(0).Height

If Not InStr(UCase(Command$), "/FLAT") = 0 Then
  xLong1 = eButton(0).hwnd
  Call SetWindowLongA(xLong1, -16, GetWindowLongA(xLong1, -16) Or &H8000&)
  eButton(0).Refresh
  xLong1 = eButton(1).hwnd
  Call SetWindowLongA(xLong1, -16, GetWindowLongA(xLong1, -16) Or &H8000&)
  eButton(1).Refresh
  xLong1 = eButton(2).hwnd
  Call SetWindowLongA(xLong1, -16, GetWindowLongA(xLong1, -16) Or &H8000&)
  eButton(2).Refresh
  xLong1 = eButton(3).hwnd
  Call SetWindowLongA(xLong1, -16, GetWindowLongA(xLong1, -16) Or &H8000&)
  eButton(3).Refresh
  xLong1 = eButton(4).hwnd
  Call SetWindowLongA(xLong1, -16, GetWindowLongA(xLong1, -16) Or &H8000&)
  eButton(4).Refresh
  ctMenuA1.FlatButtons = True
  End If

lHwnd = CreateWindowEx(&H20&, "static", "", &H0&, 0&, 0&, 0&, 0&, 0&, 0&, CLng(App.hInstance), 0&)
lpPrevWndProc = SetWindowLongA(lHwnd, -4, AddressOf WindowProc2)

RegisterHotKey lHwnd, &HBF22&, &H3, &H22 'PgDn
RegisterHotKey lHwnd, &HBF23&, &H3, &H23 'End
RegisterHotKey lHwnd, &HBF2D&, &H3, &H2D 'Ins
RegisterHotKey lHwnd, &HBF60&, &H3, &H60 'kp0 (ins)-
RegisterHotKey lHwnd, &HBF61&, &H3, &H61 'kp1 End-
RegisterHotKey lHwnd, &HBF63&, &H3, &H63 'kp3 (pgdn)-

If xInitSkipper Then Exit Sub

xDisplayMode = 255
ctMenuA1.TextHeight = 12
xInitSkipper = True
vBool(1) = True

Me.Icon = LoadResPicture(105, 1)

eImage(0).Picture = LoadResPicture(100, 1)

eCheckBox(0).Caption = LoadResString(210)
eCheckBox(1).Caption = LoadResString(211)
eCheckBox(2).Caption = LoadResString(212)
eCheckBox(3).Caption = LoadResString(213)
eCheckBox(4).Caption = LoadResString(214)
eCheckBox(5).Caption = LoadResString(215)


iView.Picture = LoadResPicture(100, 0)
eImage(1).Picture = LoadResPicture(110, 0)

Me.Caption = LoadResString(12)
If App.Revision = 0 Then
  eLabel(0).Caption = Replace(LoadResString(100), "$", Trim$(Str(App.Major)) + "." + Right("00" + Trim(Str(App.Minor)), 2))
  Else
  eLabel(0).Caption = Replace(Replace(LoadResString(101), "$", Trim$(Str(App.Major)) + "." + Right("00" + Trim(Str(App.Minor)), 2)), "%", Trim(Str(App.Revision)))
  End If
eLabel(1).Caption = Replace(LoadResString(102), "|", vbCr)
eLabel(2).Caption = LoadResString(103)
eLabel(3).Caption = Replace(LoadResString(104), "|", vbCr)

mIMenu(0).Caption = LoadResString(260)
mIMenu(2).Caption = LoadResString(261)
mIMenu(3).Caption = LoadResString(262)
mIMenu(4).Caption = LoadResString(263)
mIMenu(6).Caption = LoadResString(275)
mIMenu(8).Caption = LoadResString(264)
mIMenu(10).Caption = LoadResString(265)

Me.Left = Int((Screen.Width - Me.Width) / 2)
Me.Top = Int((Screen.Height - Me.Height) / 2)
Call SetWindowPos(Me.hwnd, -1, -1, -1, 0, 0, 3)
Me.Visible = True


xChar1 = Space(1024)
Call GetWindowsDirectoryA(xChar1, 1024)
xWinDir = LCase(Left(xChar1, InStr(xChar1, vbNullChar) - 1))
If Not Right(xWinDir, 1) = "\" Then
  xWinDir = xWinDir & "\"
  End If


On Error GoTo Er1

Close 1
xChar1 = AppBase("LST")
Open xChar1 For Input As 1
On Error GoTo Er2
If EOF(1) Then
  xLong2 = 1
  GoTo Rsx
  End If
  Input #1, xChar1
  If Not xChar1 = QTaskIniString Then
    xLong2 = 2
    GoTo Rsx
    End If

If EOF(1) Then
  xLong2 = 1
  GoTo Rsx
  End If
  
  Input #1, xChar1
  xChar1 = Mid(xChar1, InStr(xChar1 + "=", "=") + 1)
  If Not Len(xChar1) = 5 Then
    xLong2 = 1
    GoTo Rsx
    End If
  For xLong1 = 0 To 3
    If Mid(xChar1, xLong1 + 1, 1) = "1" Then
      vBool(xLong1) = True
      eCheckBox(xLong1).Value = 1
      Else
      vBool(xLong1) = False
      eCheckBox(xLong1).Value = 0
      End If
    Next
  If Right(xChar1, 1) = "1" Then
    vBool(5) = True
    eCheckBox(5).Value = 1
    Else
    vBool(5) = False
    eCheckBox(5).Value = 0
    End If
If EOF(1) Then
  xLong2 = 1
  vBool(0) = False
  eCheckBox(0).Value = 0
  GoTo Rsx
  End If
  
Line Input #1, xChar1
If Not LCase(Trim(xChar1)) = "windir=" & xWinDir Then
  xLong2 = 3
  vBool(0) = False
  eCheckBox(0).Value = 0
  End If
  
If EOF(1) Then
  xLong2 = 1
  vBool(0) = False
  eCheckBox(0).Value = 0
  GoTo Rsx
  End If
  
Line Input #1, xChar1
If Not LCase(Trim(xChar1)) = "appdir=" & LCase(AppBase(vbNullChar)) Then
  xLong2 = 4
  vBool(0) = False
  eCheckBox(0).Value = 0
  End If
  

Do
  If EOF(1) Then Exit Do
  Line Input #1, xChar1
  'xChar1 = Trim(xChar1)
  If LCase(Left(xChar1, 8)) = "autorun=" Then
    xChar1 = Mid(xChar1, 9)
    If Not (xChar1 = "" Or xKeyOldCount = MaxArray) Then
      xKeyOld(xKeyOldCount) = xChar1
      xKeyOldCount = xKeyOldCount + 1
      End If
    Else
    xTaskMode(xTaskCount) = CByte(Val(Left(xChar1, 1&)))
    xChar1 = Mid(xChar1, InStr(xChar1, "(") + 1)
    xLong1 = InStr(xChar1, ")")
    If Not xLong1 = 0 Then
      xLong1 = Val(Left(xChar1, xLong1 - 1))
      If Not xLong1 < 0 And Not xLong1 > MaxLog Then
        xTaskBlocks(xTaskCount) = xLong1
        End If
      Else
      xTaskBlocks(xTaskCount) = 0
      End If
    xChar1 = Mid(xChar1, InStr(xChar1 + ":", ":") + 1)
    xChar1 = LCase(Trim(xChar1))
    If Not (xChar1 = "" Or xTaskCount = MaxArray) Then
      xTask(xTaskCount) = xChar1
      xTaskCount = xTaskCount + 1
      End If
    End If
  Loop

If Not xLong2 = 0 Then GoTo Rsx

Rs1:
On Error GoTo 0

mIMenu(8).Checked = vBool(0)

Close 1
If vBool(0) Then
  ctMenuA1.ItemCount = 6
  ctMenuA1.SetItem 3, LoadResString(203), 113
  ctMenuA1.SetItem 4, LoadResString(204), 114
  ctMenuA1.SetItem 5, LoadResString(205), 115
  mIMenu(2).Visible = True
  Else
  ctMenuA1.ItemCount = 5
  ctMenuA1.SetItem 3, LoadResString(204), 114
  ctMenuA1.SetItem 4, LoadResString(205), 115
  End If
ctMenuA1.SetItem 0, LoadResString(200), 110
ctMenuA1.SetItem 1, LoadResString(201), 111
ctMenuA1.SetItem 2, LoadResString(202), 112


SysTrayIcon.cbSize = 88&
SysTrayIcon.hwnd = eButtonFreeUp.hwnd
SysTrayIcon.uId = Me.Icon.Handle
SysTrayIcon.uFlags = 7
SysTrayIcon.uCallBackMessage = 512
SysTrayIcon.hIcon = Me.Icon

If vBool(3) And xLong2 = 0 Then
  Me.Visible = False
  Me.WindowState = 0
  xTrayIconMode = True
  SysTrayIcon.hIcon = Me.Icon
  SysTrayIcon.szTip = Me.Caption & vbNullChar
  Shell_NotifyIconA 0, SysTrayIcon
  End If

If Not InStr(UCase$(Command$), "/AUTORUN") = 0 Then
  Me.Enabled = False
  xLong1 = Timer
  Do While Abs(Timer - xLong1) < 12: DoEvents: Loop
  Me.Enabled = True
  End If


SetTimer Me.hwnd, 0, 1000, AddressOf eTimerEvent
If Not InStr(UCase$(Command$), "/FREEUP") = 0 Then
  eButtonFreeUp.Value = 1
  End If





'Stop
If RegOpenKeyExA(&H80000001, "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", 0&, 983103, xLong1) = 0& Then
  xLong3 = 1024: xChar1 = Space(xLong3)
  If RegQueryValueExA(xLong1, "Startup", 0&, xLong2, ByVal xChar1, xLong3) = 0& Then
    'If UCase(Left(xChar1, xLong3 - 1)) = UCase(AppBase(vbnullchar)) + " /AUTORUN" Then
    '  eCheckBox(4).Value = 1
    '  End If
    
    xAutoStartDir = Left(xChar1, xLong3 - 1)
    If Not Right(xAutoStartDir, 1) = "\" Then
      xAutoStartDir = xAutoStartDir & "\"
      End If
'    Stop
    End If
  RegCloseKey (xLong1)
  End If



xInitSkipper = False

ctMenuA1.CurrentItem = 1
RefreshKeys True
xFreeMem

If Not InStr(UCase(Command$), "/AUTOQUIT") = 0 Then
  xAutoQuitTime = Timer * 100 + 1000
  End If

Exit Sub

Er1:
Resume Rsx

Er2:
xLong2 = 1
Resume Rsx

Rsx:
On Error GoTo 0


vBool(0) = False
mIMenu(8).Checked = False

If xLong2 = 1 Or xLong2 = 2 Then
  xLong1 = MsgBox(Replace(LoadResString(111 + xLong2), "|", vbCr), vbQuestion + vbYesNo, LoadResString(110))
  Else
  xLong1 = MsgBox(Replace(LoadResString(111 + xLong2), "|", vbCr), vbQuestion + vbYesNoCancel, LoadResString(110))
  End If

If Not xLong1 = vbCancel Then
  vBool(1) = True
  vBool(2) = False
  vBool(3) = True
  vBool(5) = True
  xTaskCount = 0&
  Erase xTask
  Erase xTaskMode
  Erase xTaskBlocks
  If xLong1 = vbYes Then
    xChar1 = Space(1024)
    Call GetSystemDirectoryA(xChar1, 1024)
    xChar1 = LCase(Left(xChar1, InStr(xChar1, vbNullChar) - 1))
    If Not Right(xChar1, 1) = "\" Then xChar1 = xChar1 + "\"
    xChar2 = xWinDir
    If Not Right(xChar2, 1) = "\" Then xChar2 = xChar2 + "\"
    xTask(0) = xChar2 & "explorer.exe"
    xTask(1) = xChar1 & "kernel32.dll"
    xTask(2) = xChar1 & "mmtask.tsk"
    xTask(3) = xChar1 & "mprexe.exe"
    xTask(4) = xChar1 & "msgsrv32.exe"
    xTask(5) = LCase(AppBase(vbNullChar))
    xTask(6) = xChar1 & "rnaapp.exe"
    xTask(7) = xChar2 & "rundll.exe"
    xTask(8) = xChar2 & "rundll32.exe"
    xTask(9) = xChar1 & "spool32.exe"
    xTask(10) = xChar1 & "tapisrv.exe"
    xTask(11) = xChar1 & "winoa386.mod"
    xTaskMode(0) = cByte1
    xTaskMode(1) = cByte1
    xTaskMode(2) = cByte1
    xTaskMode(3) = cByte1
    xTaskMode(4) = cByte1
    xTaskMode(5) = cByte1
    xTaskMode(6) = cByte1
    xTaskMode(7) = cByte1
    xTaskMode(8) = cByte1
    xTaskMode(9) = cByte1
    xTaskMode(10) = cByte1
    xTaskMode(11) = cByte1
    xTaskCount = 12
    Else
    xTask(0) = LCase(AppBase(vbNullChar))
    xTaskMode(0) = cByte1
    xTaskCount = 1
    End If
  End If

xInitSkipper = False
RefreshKeys False, True
GoTo Rs1
End Sub

Private Sub Form_Resize()
Static xLong1 As Long
Static xLong2 As Long

xLong1 = Me.ScaleWidth - xSpMenu - xSpLeft '- ctMenuA1.Left - lView.Left
'xLong2 = xSpMenu - xSpLeft 'eButton(0).Left
If xLong1 < 0 Then xLong1 = 0
lView.Width = xLong1
sView.Width = xLong1
Select Case xDisplayMode
  Case 0
    If vBool(0) Then
      xLong1 = xLong1 \ 5
      Else
      xLong1 = xLong1 \ 4
      End If
  Case 2
    If vBool(0) Then
      xLong1 = xLong1 \ 3
      Else
      xLong1 = xLong1 \ 4
      End If
  Case 1, 5
    xLong1 = xLong1 \ 4
  Case 3
    xLong1 = xLong1 \ 5
  Case 4
    xLong1 = xLong1 \ 3 '2
  End Select

'xLong2 = xSpMenu
eButton(0).Width = xLong1
eButton(1).Left = xSpMenu + xLong1
eButton(1).Width = xLong1
eButton(2).Left = xSpMenu + 2 * xLong1
eButton(2).Width = xLong1
eButton(3).Left = xSpMenu + 3 * xLong1
eButton(3).Width = xLong1
eButton(4).Left = xSpMenu + 4 * xLong1
eButton(4).Width = xLong1
  
xLong2 = Me.ScaleHeight
xLong1 = xLong2 - xSpTop - xSpButton ' 2 * lView.Top - eButton(0).Height
If xLong1 < 0 Then xLong1 = 0
sView.Height = xLong1
lView.Height = xLong1
iView.Height = xLong1 ' lView.Height

xLong1 = xLong1 + xSpTop
eButton(0).Top = xLong1 ' + xSpTop ' + lView.Top
eButton(1).Top = xLong1 ' + xSpTop '+ lView.Top
eButton(2).Top = xLong1 ' + xSpTop '+ lView.Top
eButton(3).Top = xLong1 ' + xSpTop '+ lView.Top
eButton(4).Top = xLong1 ' + xSpTop '+ lView.Top
xLong1 = xLong2 - 2 * xSpTop '2 * lView.Top
If xLong1 < 0 Then xLong1 = 0
ctMenuA1.Height = xLong1
If xDisplayMode = 4 Then xInfoRess
If vBool(3) And Me.WindowState = 1 Then
  Shell_NotifyIconA 2, SysTrayIcon
  Shell_NotifyIconA 0, SysTrayIcon
  Me.Visible = False
  Me.WindowState = 0
  xTrayIconMode = True
  End If
End Sub

Private Sub Form_Terminate()
If xInitSkipper Then Exit Sub

Do While xTimer1: DoEvents: Loop
KillTimer Me.hwnd, 0
Do While xTimer1: DoEvents: Loop
UnregisterHotKey lHwnd, &HBF22& 'PgDn
UnregisterHotKey lHwnd, &HBF23& 'End
UnregisterHotKey lHwnd, &HBF2D& 'Ins
UnregisterHotKey lHwnd, &HBF60& 'kp0 (ins)
UnregisterHotKey lHwnd, &HBF61& 'kp1 (end)
UnregisterHotKey lHwnd, &HBF63& 'kp3 (pgdn)
Call SetWindowLongA(lHwnd, -4, lpPrevWndProc)
Call DestroyWindow(lHwnd)
If vBool(3) Then Shell_NotifyIconA 2, SysTrayIcon
End Sub

Private Sub Form_Unload(Cancel As Integer)
Dim xChar1 As String
Dim xLong1 As Long

If xIsFreeing Then
  Cancel = 1
  Else
  Me.WindowState = 1
  Me.Enabled = False
  xInitSkipper = True
  xFreeingCounter = xMemToFreeUp
  xMemToFreeUp = 0
  xCancelFreeing = True
Do While xTimer1: DoEvents: Loop
  Call KillTimer(Me.hwnd, 0)
  Do While xTimer1: DoEvents: Loop
  UnregisterHotKey lHwnd, &HBF22& 'PgDn
  UnregisterHotKey lHwnd, &HBF23& 'End
  UnregisterHotKey lHwnd, &HBF2D& 'Ins
  UnregisterHotKey lHwnd, &HBF60& 'kp0 (ins)
  UnregisterHotKey lHwnd, &HBF61& 'kp1 (end)
  UnregisterHotKey lHwnd, &HBF63& 'kp3 (pgdn)
  Call SetWindowLongA(lHwnd, -4, lpPrevWndProc)
  Call DestroyWindow(lHwnd)
  On Error GoTo Er1
  Close 1
  xChar1 = AppBase("LST")
  Open xChar1 For Output As 1
  Print #1, QTaskIniString
  Print #1, "Settings=" + BoolValue(vBool(0)) + BoolValue(vBool(1)) + BoolValue(vBool(2)) + BoolValue(vBool(3)) + BoolValue(vBool(5))
  Print #1, "WinDir=" & xWinDir
  Print #1, "AppDir=" & LCase(AppBase(vbNullChar))
  For xLong1 = 0 To xKeyOldCount - 1
    Print #1, "AutoRun=" & xKeyOld(xLong1)
    Next
  For xLong1 = 0 To xTaskCount - 1
    Print #1, Left(Trim(Str(xTaskMode(xLong1))) + " (" + Trim(Str(xTaskBlocks(xLong1))) + "):" + Space(13), 13) + xTask(xLong1)
    Next
Rs1:
  If vBool(3) Then Shell_NotifyIconA 2, SysTrayIcon
  Close 1
  xInitSkipper = True
  End If
Exit Sub

Er1:
Resume Rs1
End Sub

Private Sub lView_DblClick()
If xDisplayMode = 1 Then eButton_Click 0
End Sub

Private Sub lView_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = 93 Then
  If xDisplayMode = 1 Then
    PopupMenu m0, , , , mOMenu(0)
    Else
    PopupMenu m0
    End If
  ElseIf KeyCode = 46 And xDisplayMode = 0 Then
  eButton_Click 2
  ElseIf KeyCode = 13 And xDisplayMode = 1 Then
  eButton_Click 0
  End If
End Sub

Private Sub lView_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
  If xDisplayMode = 1 Then
    PopupMenu m0, , , , mOMenu(0)
    Else
    PopupMenu m0
    End If
  End If
End Sub

Private Sub mIMenu_Click(Index As Integer)
Dim xLong1 As Long
Dim xLong2 As Long
Dim xChar1 As String

xAutoQuitTime = 0

xUnLock = True
Select Case Index
  Case 0
    If xTrayIconMode Then
      Me.Visible = True
      xTrayIconMode = False
      End If
  Case 2
    If Not xTempCount = MaxArray Then
      xChar1 = Int2Ext(xNew(xNewCount - 1))
      For xLong1 = 0 To xTempCount - 1
        If xChar1 < Int2Ext(xNew(xNewCount - 1)) Then Exit For
        Next
      For xLong2 = xTempCount To xLong1 + 1 Step -1
        xTemp(xLong2) = xNew(xLong2 - 1)
        xTempBlocks(xLong2) = xTempBlocks(xLong2 - 1)
        Next
      xTempCount = xTempCount + 1
      xTemp(xLong1) = xNew(xNewCount - 1)
      xTempBlocks(xLong1) = xNewBlocks(xNewCount - 1)
      xNewCount = xNewCount - 1
      If xDisplayMode = 0 Then
        lView.RemoveItem xNewCount
        If Not xNewCount = 0 Then
          lView.Selected(xNewCount - 1) = True
          End If
        End If
      If xDisplayMode = 4 Then
        lView.AddItem Int2Ext(xTemp(xLong1), xTempBlocks(xLong1)), xLong1
        For xLong2 = 0 To xTempCount - 1
          lView.Selected(xLong2) = xLong2 = xLong1
          Next
        End If
      UpdateTemp
      End If
  Case 3, 4
    If Not xTaskCount = MaxArray Then
      xChar1 = Int2Ext(xNew(xNewCount - 1))
      For xLong1 = 0 To xTaskCount - 1
        If xChar1 < Int2Ext(xTask(xLong1)) Then Exit For
        Next
      For xLong2 = xTaskCount To xLong1 + 1 Step -1
        xTask(xLong2) = xTask(xLong2 - 1)
        xTaskBlocks(xLong2) = xTaskBlocks(xLong2 - 1)
        xTaskMode(xLong2) = xTaskMode(xLong2 - 1)
        Next
      xTaskCount = xTaskCount + 1
      xTask(xLong1) = xNew(xNewCount - 1)
      xTaskBlocks(xLong1) = xNewBlocks(xNewCount - 1)
      xTaskMode(xLong1) = cByte4 - CByte(Index)
      xNewCount = xNewCount - 1&
      If xDisplayMode = 0 Then
        lView.RemoveItem xNewCount
        If Not xNewCount = 0 Then
          lView.ListIndex = xNewCount - 1
          End If
        End If
      If xDisplayMode = 2 Then
        sView.AddItem Int2Ext(xTask(xLong1), xTaskBlocks(xLong1)), xLong1
        sView.Selected(xLong1) = (xTaskMode(xLong1) = cByte1)
        sView.ListIndex = xLong1
        End If
      UpdateTemp
      End If
  Case 6
    If xIsFreeing Then
      xCancelFreeing = True
      Else
      eButtonFreeUp.Value = True
      End If
  Case 8
    eCheckBox_Click 0
  Case 10
    Unload Me
  End Select
xUnLock = False
End Sub

Private Sub mOMenu_Click(Index As Integer)
eButton_Click Index \ 2
End Sub

Private Sub sView_DblClick()
If xDisplayMode = 3 Then
  sView.Refresh
  DoEvents
  eButton_Click 2
  sView.Refresh
  End If
End Sub

Private Sub sView_ItemCheck(Item As Integer)
Dim xLong1 As Long

xLong1 = sView.ListIndex
sView.Refresh
'DoEvents
If Not (xLong1 = NoListIndex Or xUnLock) Then
  If xDisplayMode = 2 Then
    sView.Selected(xLong1) = (xTaskMode(xLong1) = cByte1)
    Else
    sView.Selected(xLong1) = (xKeyUsed(xLong1) = cByte1)
    End If
  End If
sView.Refresh
End Sub

Private Sub xInfoRess()
Static xLong1 As Long
xLong1 = lView.Width
iView.Width = xLong1 ' lView.Width
'iView.Height = xLong1 ' lView.Height
'xLong1 = Int((iView.Width - eLabel(3).Width) / 2)
eImage(1).Left = (xLong1 - eImage(1).Width) / 2
xLong1 = Int((xLong1 - eLabel(3).Width) / 2)
'eImage(1).Left = (iView.Width - eImage(1).Width) / 2
eLabel(2).Left = xLong1
eLabel(3).Left = xLong1
eLabel(4).Left = xLong1
End Sub

Private Function xFreeMem(Optional ByVal ForceFreeUp As Boolean) As Long
Dim xMemStatus1 As MemoryStatus

If xIsFreeing Then
  xFreeMem = -Int(xFreeingCounter * 100& / xMemToFreeUp) - 1&
  Exit Function
  End If


GlobalMemoryStatus xMemStatus1
If xMemToFreeUp = 0& Then
  xGlobalMem = Int(xMemStatus1.dwTotalPhys / &H100000)
  If xGlobalMem < 0& Then xGlobalMem = 2048 - xGlobalMem
  Select Case xGlobalMem
    Case Is < 66&
      ' Windows takes about 64 MB itself. On slow computers QuickTask is not recommened
      ' Avoiding lots of freeups, only if <1 MB free
      ' Freeing up 4 MB only
      xMemToFreeUp = 4&
      xMemFreeBelow = 0&
    Case 66& To 89&
      ' Freeing usefull now.
      xMemToFreeUp = 8&
      xMemFreeBelow = 1&
    Case 90& To 126&
      xMemFreeBelow = 3&
      xMemToFreeUp = 32
    Case 127& To 190&
      xMemFreeBelow = 6&
      xMemToFreeUp = 64&
    Case Is > 190&
      xMemFreeBelow = 12&
      xMemToFreeUp = xGlobalMem - 92&
      If xMemToFreeUp > 512& Then xMemToFreeUp = 512&
      ' Not yet sure about how long it takes, if it's fast enough and usefull, we'll free up more
    End Select
  End If

xFreeMem = Int(xMemStatus1.dwAvailPhys / &H100000)
If xFreeMem < 0& Then xFreeMem = 2048& - xFreeMem
If vBool(2) And (xFreeMem < xMemFreeBelow Or ForceFreeUp) Then
  eButtonFreeUp.Value = True
  End If
End Function

Private Sub TerminateTask(ByVal xChar1 As String, ByVal xLong1 As Long)
On Error Resume Next
Static xLong2 As Long

xLong2 = OpenProcess(&H1F0FFF, 0&, xLong1)
Call TerminateProcess(xLong2, 0&)
Call CloseHandle(xLong2)
For xLong1 = 0 To xCurrentCount - 1
  If xCurrent(xLong1) = xChar1 Then
    If Not xCurrentBlocks(xLong1) = MaxLog Then
      xCurrentBlocks(xLong1) = xCurrentBlocks(xLong1) + 1
      If xDisplayMode = 1 Then lView.List(xLong1) = Int2Ext(xChar1, xCurrentBlocks(xLong1))
      End If
    End If
  Next
SetWidth
On Error GoTo 0
End Sub

Private Function BoolValue(xBool1 As Boolean) As String
If xBool1 Then
  BoolValue = "1"
  Else
  BoolValue = "0"
  End If
End Function

Private Sub sView_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = 93 Then
  sView.Refresh
  DoEvents
  If xDisplayMode = 2 Then
    PopupMenu m0
    Else
    PopupMenu m0, , , , mOMenu(0)
    End If
  sView.Refresh
  ElseIf KeyCode = 46 Then
  sView.Refresh
  DoEvents
  If xDisplayMode = 1 Then
    eButton_Click 2
    Else
    eButton_Click 4
    End If
  sView.Refresh
  End If
End Sub

Private Sub sView_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
  sView.Refresh
  DoEvents
  If xDisplayMode = 2 Then
    PopupMenu m0
    Else
    PopupMenu m0, , , , mOMenu(4)
    End If
  sView.Refresh
  End If
End Sub

Private Sub RefreshKeys(Optional ByVal ReSelect As Boolean = False, Optional ByVal NoPopup As Boolean)
Dim xChar1 As String
Dim xChar2 As String
Dim xChar3 As String
Dim xLong1 As Long
Dim xLong2 As Long
Dim xLong3 As Long
Dim xLong4 As Long
Dim xBool1 As Boolean

xKeyCount = 0&
AddKeys 0, "Software\Microsoft\Windows\CurrentVersion\Run", 0&, cByte1
AddKeys 0, "Software\Microsoft\Windows\CurrentVersion\Run-", 0&, cByte0
AddKeys 0, "Software\Microsoft\Windows\CurrentVersion\RunServices", 0&, cByte1
AddKeys 0, "Software\Microsoft\Windows\CurrentVersion\RunServices-", 0&, cByte0
AddKeys 0, "Software\Microsoft\Windows\CurrentVersion\RunOnce", 1&, cByte1
AddKeys 0, "Software\Microsoft\Windows\CurrentVersion\RunOnce-", 1&, cByte0
AddKeys 0, "Software\Microsoft\Windows\CurrentVersion\RunOnceEx", 1&, cByte1
AddKeys 0, "Software\Microsoft\Windows\CurrentVersion\RunOnceEx-", 1&, cByte0
AddKeys 0, "Software\Microsoft\Windows\CurrentVersion\RunServicesOnce", 1&, cByte1
AddKeys 0, "Software\Microsoft\Windows\CurrentVersion\RunServicesOnce-", 1&, cByte0
AddKeys 1, "Software\Microsoft\Windows\CurrentVersion\Run", 0&, cByte1
AddKeys 1, "Software\Microsoft\Windows\CurrentVersion\Run-", 0&, cByte0
AddKeys 1, "Software\Microsoft\Windows\CurrentVersion\RunServices", 0, 1
AddKeys 1, "Software\Microsoft\Windows\CurrentVersion\RunServices-", 0, 0
AddKeys 1, "Software\Microsoft\Windows\CurrentVersion\RunOnce", 1, 1
AddKeys 1, "Software\Microsoft\Windows\CurrentVersion\RunOnce-", 1, 0
AddKeys 1, "Software\Microsoft\Windows\CurrentVersion\RunOnceEx", 1, 1
AddKeys 1, "Software\Microsoft\Windows\CurrentVersion\RunOnceEx-", 1, 0
AddKeys 1, "Software\Microsoft\Windows\CurrentVersion\RunServicesOnce", 1, 1
AddKeys 1, "Software\Microsoft\Windows\CurrentVersion\RunServicesOnce-", 1, 0

xLong1 = xKeyCount
'xChar1 = Dir(xWinDir & "*.*", 55&)
xChar3 = Dir(xAutoStartDir & "*.*", 39&)
Do
  If xChar3 = "" Then Exit Do
  If Not Left(xChar3, 1) = "." Then
'    xChar2 = xChar1 'LCase(xChar1)
'    Do
'      xLong2 = InStr(xChar2, "\")
'      If xLong2 = 0 Then Exit Do
'      xChar2 = Mid(xChar2, xLong2 + 1&)
'      Loop
    If Len(xChar3) < 31& Then
      xChar2 = Left(xChar3 + Space(34&), 34&)
      Else
      xChar2 = xChar3 & "    "
      End If
    xChar1 = xChar2 & xAutoStartDir & xChar3
    xChar2 = LCase(xChar1)
    'Stop
    For xLong2 = xLong1 To xKeyCount - 1&
      If xChar2 < xKeyCaption(xLong2) Then
        Exit For
        End If
      Next
      
    For xLong3 = xKeyCount To xLong2 + 1& Step -1&
      xKey(xLong3) = xKey(xLong3 - 1&)
      xKeyMode(xLong3) = xKeyMode(xLong3 - 1&)
      xKeyValue(xLong3) = xKeyValue(xLong3 - 1&)
      xKeyCaption(xLong3) = xKeyCaption(xLong3 - 1&)
      xKeyPreview(xLong3) = xKeyPreview(xLong3 - 1&)
      xKeyUsed(xLong3) = xKeyUsed(xLong3 - 1&)
      Next
    xKeyMode(xLong2) = 2
'    Stop
    'xKey(xLong2) = 2
    'Stop
    xKeyValue(xLong2) = xChar3
    xKeyCaption(xLong2) = xChar1
    xKeyPreview(xLong2) = xChar2
    xKeyUsed(xLong2) = cByte1
    xKeyCount = xKeyCount + 1&
    End If
  xChar3 = Dir
  Loop

xLong1 = xKeyCount
AddCustomKey xLong1, "win.ini", "[windows]", "load", cByte1
AddCustomKey xLong1, "win.ini", "[windows]", ";load", cByte0
'xLong1 = xKeyCount
AddCustomKey xLong1, "win.ini", "[windows]", "run", cByte1
AddCustomKey xLong1, "win.ini", "[windows]", ";run", cByte0
'xLong1 = xKeyCount
AddCustomKey xLong1, "system.ini", "[boot]", "scrnsave.exe", cByte1
AddCustomKey xLong1, "system.ini", "[boot]", ";scrnsave.exe", cByte0






If xDisplayMode = 3 Then
  xLong4 = sView.ListIndex
  sView.Clear
  For xLong1 = 0 To xKeyCount - 1
    sView.AddItem xKeyCaption(xLong1)
    sView.Selected(xLong1) = (xKeyUsed(xLong1) = cByte1)
    xLong2 = Len(xKeyCaption(xLong1))
    If xLong2 > xLong3 Then xLong3 = xLong2
    Next
  Call SendMessageA(sView.hwnd, 404, sWidth + xLong3 * 7, 0)
  If Not xLong4 = -1 And xLong4 < xKeyCount And ReSelect Then
    sView.ListIndex = xLong4
    End If
  End If

If vBool(5) Then
  xLong2 = -1
'  Stop
  For xLong1 = 0 To xKeyCount - 1
    xChar1 = TxtKey(xLong1)
    If Not xKeyOld(xLong1) = xChar1 Then
'      Stop
      xBool1 = True
      If xLong2 = -1 Then xLong2 = xLong1
      xKeyOld(xLong1) = xChar1
      End If
    Next
  If (Not xKeyCount = xKeyOldCount Or xBool1) And Not NoPopup Then
    If Not xDisplayMode = 3 Then
      If vBool(0) Then
        ctMenuA1.CurrentItem = 4
        Else
        ctMenuA1.CurrentItem = 3
        End If
      If Not xLong2 = -1 And xLong2 < xKeyCount And Not xKeyOldCount > xKeyCount Then
        sView.ListIndex = xLong2
        End If
      End If
      If xTrayIconMode Then
        xTrayIconMode = False
        Me.Visible = True
        xAutoQuitTime = 0
        Else
        Me.WindowState = 0
        End If
    End If
  xKeyOldCount = xKeyCount
  End If

xInitSkipper = True
eCheckBox(4).Value = 0
If RegOpenKeyExA(&H80000002, "Software\Microsoft\Windows\CurrentVersion\Run", 0&, 983103, xLong1) = 0& Then
  xLong3 = 1024: xChar1 = Space(xLong3)
  If RegQueryValueExA(xLong1, "QuickTask3", 0&, xLong2, ByVal xChar1, xLong3) = 0& Then
    If UCase(Left(xChar1, xLong3 - 1)) = UCase(AppBase(vbNullChar)) + " /AUTORUN" Then
      eCheckBox(4).Value = 1
      End If
    End If
  RegCloseKey (xLong1)
  End If
xInitSkipper = False
End Sub

Private Sub AddKeys(ByVal xKey1 As Long, ByVal xKey2 As String, ByVal RunOnce As Long, ByVal IsChecked As Byte)
Dim xLong1 As Long
Dim xLong2 As Long
Dim xLong3 As Long
Dim xLong4 As Long
Dim xChar1 As String
Dim xChar2 As String
Dim xChar3 As String
Dim xChar4 As String

If RegOpenKeyExA(&H80000001 + xKey1, xKey2, 0&, 983103, xLong1) = 0& Then
  Do
    If xKeyCount = xKeyMax Then Exit Do
    xChar2 = Space(1024): xLong2 = 1024
    If RegEnumKeyA(xLong1, xLong3, ByVal xChar2, xLong2) = &O0 Then
        xChar2 = Left(xChar2, InStr(xChar2, vbNullChar) - 1)
        xChar3 = Replace(LoadResString(31 + RunOnce), "$", xChar2)
        xChar1 = LCase(xChar3)
        For xLong2 = 0 To xKeyCount - 1
          If xChar1 < LCase(xKeyCaption(xLong2)) Then Exit For
          Next
        If IsChecked = cByte0 Then
          xChar1 = Left(xKey2, Len(xKey2) - 1)
          For xLong4 = 0 To xKeyCount
            If xKeyMode(xLong4) = xKey1 + 16 And xKey(xLong4) = xChar1 And _
               xKeyValue(xLong4) = xChar2 Then
               xLong2 = -1
               Exit For
               End If
            Next
          End If
        If Not xLong2 = -1& Then
          For xLong4 = xKeyCount To xLong2 + 1& Step -1&
            xKey(xLong4) = xKey(xLong4 - 1&)
            xKeyMode(xLong4) = xKeyMode(xLong4 - 1&)
            xKeyValue(xLong4) = xKeyValue(xLong4 - 1&)
            xKeyCaption(xLong4) = xKeyCaption(xLong4 - 1&)
            xKeyPreview(xLong4) = xKeyPreview(xLong4 - 1&)
            xKeyUsed(xLong4) = xKeyUsed(xLong4 - 1&)
            Next
          xKeyMode(xLong2) = xKey1 + 16
          xKey(xLong2) = xKey2
          xKeyValue(xLong2) = xChar2
          xKeyCaption(xLong2) = xChar3
          xKeyPreview(xLong2) = ""
          xKeyUsed(xLong2) = IsChecked
          xKeyCount = xKeyCount + 1&
        End If
      Else
      Exit Do
      End If
    xLong3 = xLong3 + 1
    Loop
  xLong4 = 0
  Do
    If xKeyCount = xKeyMax Then Exit Do
    xChar2 = Space(1024)
    xChar3 = Space(1024)
    If RegEnumValueA(xLong1, xLong4, ByVal xChar2, 1024, 0, xLong3, ByVal xChar3, 1024) = 0& Then
      If Not InStr(xChar3, vbNullChar) = 0 Then
          xChar2 = Left(xChar2, InStr(xChar2, vbNullChar) - 1)
          xLong2 = xKeyCount
          xChar3 = Left(xChar3, InStr(xChar3, vbNullChar) - 1)
          'xChar1 = LCase(Int2Ext(SimpleFile(xChar3)))
          'xChar4 = xChar1
          
          If RunOnce = 1 Then
            xChar1 = Replace(LoadResString(30), "$", xChar2)
            Else
            xChar1 = xChar2
'            If Len(xChar2) < 31 Then
'              xChar1 = Left(xChar2 + Space(34), 34)
'              Else
'              xChar1 = xChar2 & "    "
'              End If
            End If
            
          If Len(xChar1) < 31 Then
            xChar1 = Left(xChar1 + Space(34), 34)
            Else
            xChar1 = xChar1 & "    "
            End If
'          Stop
          xChar4 = xChar1 & xChar3
          xChar1 = LCase(xChar4)
          
'          Stop
          For xLong2 = 0 To xKeyCount - 1
            'If xChar1 < LCase(xKeyCaption(xLong2)) Then Exit For
            If xChar1 < LCase(xKeyCaption(xLong2)) Then Exit For
            Next
          If IsChecked = cByte0 Then
            xChar1 = Left(xKey2, Len(xKey2) - 1)
            For xLong3 = 0 To xKeyCount
              If xKeyMode(xLong3) = xKey1 And xKey(xLong3) = xChar1 And _
                 xKeyValue(xLong3) = xChar2 Then
                 xLong2 = -1
                 Exit For
                 End If
              Next
            End If
          If Not xLong2 = -1& Then
            For xLong3 = xKeyCount To xLong2 + 1& Step -1&
              xKey(xLong3) = xKey(xLong3 - 1&)
              xKeyMode(xLong3) = xKeyMode(xLong3 - 1&)
              xKeyValue(xLong3) = xKeyValue(xLong3 - 1&)
              xKeyCaption(xLong3) = xKeyCaption(xLong3 - 1&)
              xKeyPreview(xLong3) = xKeyPreview(xLong3 - 1&)
              xKeyUsed(xLong3) = xKeyUsed(xLong3 - 1&)
              Next
            xKeyMode(xLong2) = xKey1
            xKey(xLong2) = xKey2
            xKeyValue(xLong2) = xChar2

'            xChar1 = xChar2
'            If RunOnce = 1 Then
'              xChar1 = Replace(LoadResString(30), "$", xChar1)
'              End If
'
'            If Len(xChar1) < 31 Then
'              xChar1 = Left(xChar1 + Space(34), 34)
'              Else
'              xChar1 = xChar1 & "    "
'              End If
            xKeyCaption(xLong2) = xChar4 'xChar1 & xChar3 ' xChar2 & "   " & xChar3 '4
            
            
            'If RunOnce = 1 Then
            '  xKeyCaption(xLong2) = Replace(LoadResString(30), "$", xKeyCaption(xLong2))
            '  End If
            xKeyPreview(xLong2) = xChar3
            xKeyUsed(xLong2) = IsChecked
            xKeyCount = xKeyCount + 1&
            End If
        End If
      Else
      Exit Do
      End If
    xLong4 = xLong4 + 1
    Loop
  Call RegCloseKey(xLong1)
  End If
End Sub

'Private Function SimpleFile(ByVal xChar1 As String) As String
'Static xLong1 As Long
''Dim xLong2 As Long
'
'xChar1 = Trim(xChar1)
'If Left(xChar1, 1) = Chr(34) And Not InStr(2, xChar1, Chr(34)) = 0 Then
'  SimpleFile = Mid(xChar1, 2, InStr(2, xChar1, Chr(34)) - 2)
'  Else
'  Do
'    xLong1 = InStr(xChar1, "\")
'    If Not xLong1 = 0 Then
'      SimpleFile = SimpleFile & Left(xChar1, xLong1)
'      xChar1 = Mid(xChar1, xLong1 + 1)
'      Else
'      SimpleFile = SimpleFile & Left(xChar1, InStr(xChar1 + " ", " ") - 1)
'      Exit Do
'      End If
'    Loop
'  End If
'End Function

Private Sub CheckMinimize()
If vBool(4) And vBool(1) Then
  If vBool(3) Then
    xTrayIconMode = True
    Me.Visible = False
    Else
    Me.WindowState = 1
    End If
  End If
ctMenuA1.CurrentItem = 1
End Sub

'Private Function SimpleChar(ByVal xChar1 As String) As String
'Static xLong1 As Long
'Static xChar2 As String
'
'For xLong1 = 1 To Len(xChar1)
'  xChar2 = Mid(xChar1, xLong1, 1)
'  Select Case Asc(xChar2)
'    Case 32 To 126, 128 To 255
'      SimpleChar = SimpleChar + xChar2
'    End Select
'  Next
'End Function

Public Sub PopupNow()
If Me.WindowState = 1 Or xInitSkipper Or xTrayIconMode Then
  ctMenuA1.CurrentItem = 1
  If xTrayIconMode Then
    xTrayIconMode = False
    Me.Visible = True
    Else
    Me.WindowState = 0
    End If
  Me.Show
  Call SetWindowPos(Me.hwnd, -1, -1, -1, 0, 0, 3)
  Else
  Me.WindowState = 1
  End If
End Sub

Private Function SetWidth()
Static xLong1 As Long
Static xLong2 As Long
Static xLong3 As Long
xLong3 = 0

Select Case xDisplayMode
  Case 0
    For xLong1 = 0 To xNewCount - 1
      xLong2 = Len(Int2Ext(xNew(xLong1), xNewBlocks(xLong1)))
      If xLong2 > xLong3 Then xLong3 = xLong2
      Next
    Call SendMessageA(lView.hwnd, 404, lWidth + xLong3 * 7, 0)
  Case 1
    For xLong1 = 0 To xCurrentCount - 1
      xLong2 = Len(Int2Ext(xCurrent(xLong1), xCurrentBlocks(xLong1)))
      If xLong2 > xLong3 Then xLong3 = xLong2
      Next
    Call SendMessageA(lView.hwnd, 404, lWidth + xLong3 * 7, 0)
  Case 2
    For xLong1 = 0 To xTaskCount - 1
      xLong2 = Len(Int2Ext(xTask(xLong1), xTaskBlocks(xLong1)))
      If xLong2 > xLong3 Then xLong3 = xLong2
      Next
    Call SendMessageA(sView.hwnd, 404, sWidth + xLong3 * 7, 0)
  Case 4
    For xLong1 = 0 To xTempCount - 1
      xLong2 = Len(Int2Ext(xTemp(xLong1), xTempBlocks(xLong1)))
      If xLong2 > xLong3 Then xLong3 = xLong2
      Next
    Call SendMessageA(lView.hwnd, 404, sWidth + xLong3 * 7, 0)
  End Select
End Function

Private Sub UpdateTemp()
Static xLong1 As Long
Static xChar1 As String
Static xOldTemp As String

If xNewCount = 0 Then
  If Not xOldTemp = "" Then
    mIMenu(2).Caption = LoadResString(261)
    mIMenu(3).Caption = LoadResString(262)
    mIMenu(4).Caption = LoadResString(263)
    mIMenu(2).Enabled = False
    mIMenu(3).Enabled = False
    mIMenu(4).Enabled = False
    xOldTemp = ""
    End If
  Else
  xChar1 = xNew(xNewCount - 1)
  If Not xChar1 = xOldTemp Then
    If xOldTemp = "" Then
      mIMenu(2).Enabled = True
      mIMenu(3).Enabled = True
      mIMenu(4).Enabled = True
      End If
    xOldTemp = xChar1
    Do
      xLong1 = InStr(xChar1, "\")
      If xLong1 = 0 Then Exit Do
      xChar1 = Mid(xChar1, xLong1 + 1)
      Loop
    mIMenu(2).Caption = Replace(LoadResString(270), "$", xChar1)
    mIMenu(3).Caption = Replace(LoadResString(271), "$", xChar1)
    mIMenu(4).Caption = Replace(LoadResString(272), "$", xChar1)
    End If
  End If
End Sub

Private Function TxtKey(ByVal xLong1 As Long) As String
Select Case xKeyMode(xLong1)
  Case 0: TxtKey = "0"
  Case 1: TxtKey = "1"
  Case 16: TxtKey = "2"
  Case 17: TxtKey = "3"
  End Select
TxtKey = Chr(48& + xKeyUsed(xLong1)) & TxtKey & LCase(xKey(xLong1) & "##" & xKeyPreview(xLong1))
End Function

Private Sub AddCustomKey(ByVal StartIndex As Long, ByVal FileName As String, ByVal Section As String, ByVal Keyword As String, ByVal IsChecked As Byte)
Dim xLong1 As Long
Dim xLong2 As Long
Dim xChar1 As String
Dim xChar2 As String
Dim xChar3 As String
Dim xChar4 As String
'Dim xCharA1(cINICacheSize) As String

'Exit Sub
'Stop
On Error GoTo Er1
'On Error GoTo 0
Close 1
Open xWinDir & FileName For Input As 1
Do
  If EOF(1) Then Exit Do
  Line Input #1, xChar1
  If LCase(Trim(xChar1)) = Section Then
    xLong1 = Len(Keyword)
    If IsChecked = cByte0 Then
      xChar4 = Mid(Keyword, 2)
      Else
      xChar4 = Keyword
'      Stop
      End If

    Do
      If EOF(1) Then Exit Do
      Line Input #1, xChar1
      xChar1 = Trim(xChar1)
      If Left(xChar1, 1) = "[" Then Exit Do
      If LCase(Left(xChar1, xLong1)) = Keyword Then
'        Stop
        xChar1 = Trim(Mid(xChar1, xLong1 + 1))
        If Left(xChar1, 1) = "=" Then
          xChar1 = Trim(Mid(xChar1, 2))
          
          xChar3 = xChar1
'          Stop
          Do
            xLong1 = InStr(xChar3, "\")
            If xLong1 = 0 Then Exit Do
            xChar3 = Mid(xChar3, xLong1 + 1&)
            Loop
          If Len(xChar3) < 31& Then
            xChar3 = Left(xChar3 + Space(34&), 34&)
            Else
            xChar3 = xChar3 & "    "
            End If
          xChar3 = xChar3 & FileName & ", " & Section & ", " & xChar4 & "=" & xChar1
          
          xChar2 = LCase(xChar3)
          For xLong1 = StartIndex To xKeyCount - 1&
            xChar4 = LCase(xKeyCaption(xLong1))
            'If xChar2 < LCase(xKeyCaption(xLong1)) Then Exit For
            If xChar2 < xChar4 Then Exit For
            'If xChar2 = LCase(xKeyCaption(xLong1)) Then
            If xChar2 = xChar4 Then
              xLong1 = -1&
              Exit For
              End If
            Next
'          If IsChecked = cByte0 Then
'            If IsChecked = cByte0 Then
'              xChar2 = Mid(Keyword, 2)
'              Else
'              xChar2 = Keyword
'              End If
'            For xLong2 = StartIndex To xKeyCount - 1&
'              If xKeyCaption(xLong2) = xChar2 Then
'                xLong1 = -1&
'                Exit For
'                End If
'              Next
            'endif
          If Not xLong1 = -1& Then
            For xLong2 = xKeyCount To xLong1 + 1& Step -1&
              xKey(xLong2) = xKey(xLong2 - 1&)
              xKeyMode(xLong2) = xKeyMode(xLong2 - 1&)
              xKeyValue(xLong2) = xKeyValue(xLong2 - 1&)
              xKeyCaption(xLong2) = xKeyCaption(xLong2 - 1&)
              xKeyPreview(xLong2) = xKeyPreview(xLong2 - 1&)
              xKeyUsed(xLong2) = xKeyUsed(xLong2 - 1&)
              Next
            xKeyMode(xLong1) = 3&
            xKey(xLong1) = FileName
            xKeyValue(xLong1) = Section
'            Stop
            xKeyPreview(xLong1) = Keyword & "=" & xChar1
            xKeyCaption(xLong1) = xChar3
            xKeyUsed(xLong1) = IsChecked
            xKeyCount = xKeyCount + 1&
            End If
          
          
          End If
        Exit Do
        End If
      Loop
    End If
  Loop

Rs1:
On Error GoTo 0
Close 1&
Exit Sub

Er1:
Resume Rs1
End Sub

Private Sub ShowFileProperties(sFilename As String)
Dim xType1 As SHELLEXECUTEINFO

'Fill in the SHELLEXECUTEINFO structure
With xType1
  .cbSize = Len(xType1)
  .fMask = &H44C&
  .hwnd = Me.hwnd
  .lpVerb = "properties"
  .lpFile = sFilename
  .lpParameters = vbNullChar
  .lpDirectory = vbNullChar
  .nShow = 0&
  .hInstApp = App.hInstance ' 0&
  .lpIDList = 0&
  End With
Call ShellExecuteEx(xType1)
End Sub

Private Sub ChangeIniSettings(ByVal KeyID As Long, ByVal NewMode As Long)
Dim xNewContens As String
Dim xLong1 As Long
Dim xLong2 As Long
Dim xChar1 As String
Dim xChar2 As String
Dim xChar3 As String
Dim xChar4 As String
Dim xChar5 As String
Dim xChar6 As String
Dim xBool1 As Boolean

'Stop
On Error GoTo Er1
'On Error GoTo 0
Close 1
Open xWinDir & xKey(KeyID) For Input As 1
Do
  If EOF(1) Then Exit Do
  Line Input #1, xChar1
  xNewContens = xNewContens & xChar1 & vbCrLf
  If LCase(Trim(xChar1)) = xKeyValue(KeyID) Then
    If xKeyUsed(KeyID) = cByte1 Then
      xChar3 = xKeyPreview(KeyID)
      Else
      xChar3 = Mid(xKeyPreview(KeyID), 2)
      End If
    xChar3 = LCase(xChar3)
    xLong1 = InStr(xChar3, "=")
    'If Not xLong1 = 0 Then
    '  xChar3 = Mid(xChar3, xLong1 + 1)
    '  End If
    xChar4 = Mid(xChar3, xLong1 + 1&)
    xLong2 = xLong1
    xLong1 = xLong1 - 1&
    xChar3 = Left(xChar3, xLong1) ' - 1&)
    xChar5 = LCase(";" & xChar3)
    Do
      If EOF(1) Then Exit Do
      Line Input #1, xChar1
      xChar2 = LCase(Trim(xChar1))
      If Left(xChar2, 1) = "[" Then
        'xNewContens = xNewContens & xChar1 & vbCrLf
        Do
          xNewContens = xNewContens & xChar1 & vbCrLf
          If EOF(1) Then Exit Do
          Line Input #1, xChar1
          'xNewContens = xNewContens & xChar1 & vbCrLf
          Loop
        Exit Do
        End If
      If Left(xChar2, xLong1) = xChar3 Or _
        Left(xChar2, xLong2) = xChar5 Then
        If Left(xChar2, xLong1) = xChar3 Then
          xChar6 = xChar1 'Left(xChar1, xLong1)
          xChar2 = LTrim(Mid(xChar2, xLong1 + 1&))
          Else
          xChar6 = Mid(xChar1, 2&) ', xLong1)
          xChar2 = LTrim(Mid(xChar2, xLong1 + 2&))
          End If
        If Left(xChar2, 1) = "=" Then
          xChar2 = LTrim(Mid(xChar2, 2))
          If xChar2 = xChar4 Then
            If Not xBool1 Then
              xBool1 = True
              If NewMode = 0& Then
                xNewContens = xNewContens & ";" & xChar6 & vbCrLf
                ElseIf NewMode = 1& Then
                xNewContens = xNewContens & xChar6 & vbCrLf
                End If
              End If
            End If
          Else
          xNewContens = xNewContens & xChar1 & vbCrLf
          End If
        Else
        xNewContens = xNewContens & xChar1 & vbCrLf
        End If
      
      
      Loop
    Exit Do
    End If
  Loop

If xBool1 Then
  Close 1
  Open xWinDir & xKey(KeyID) For Output As 1
  Close 1
  Open xWinDir & xKey(KeyID) For Binary Access Write As 1
  Put 1, 1&, xNewContens
  End If


Rs1:
On Error GoTo 0
Close 1
Exit Sub

Er1:
Resume Rs1
End Sub


