Attribute VB_Name = "modGlobal"
Option Explicit

Public Const SoundMax = 30
Public SoundFileName(SoundMax) As String
Public SoundID(SoundMax) As Integer

Public RegisteredEM As String
Public RegisterNAME As String

Public Declare Sub FloodFill Lib "gdi32" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long)
Public Declare Sub SetLastError Lib "kernel32" (ByVal dwErrCode As Long)
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Declare Function WindowFromPoint Lib "user32" (ByVal x As Long, ByVal y As Long) As Long

Public Declare Function AdjustTokenPrivileges Lib "advapi32" (ByVal TokenHandle As Long, ByVal DisableAllPrivileges As Long, NewState As TOKEN_PRIVILEGES, ByVal BufferLength As Long, PreviousState As TOKEN_PRIVILEGES, ReturnLength As Long) As Long
Public Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As POINTAPI, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
Public Declare Function ExitWindowsEx Lib "user32" (ByVal dwOptions As Long, ByVal dwReserved As Long) As Long
Public Declare Function AddFontResource Lib "gdi32" Alias "AddFontResourceA" (ByVal lpFileName As String) As Long
Public Declare Function RemoveFontResource Lib "gdi32" Alias "RemoveFontResourceA" (ByVal lpFileName As String) As Long
Public Declare Function GetCurrentProcess Lib "kernel32" () As Long
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Public Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Public Declare Function GetVersionExA Lib "kernel32" (lpVersionInformation As OSVERSIONINFO) As Integer
Public Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function LookupPrivilegeValue Lib "advapi32" Alias "LookupPrivilegeValueA" (ByVal lpSystemName As String, ByVal lpName As String, lpLuid As LUID) As Long
Public Declare Function OpenProcessToken Lib "advapi32" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long
Public Declare Function sndPlaySound Lib "WINMM.DLL" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Public Declare Function RegQueryValueExNULL Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As Long, lpcbData As Long) As Long
Public Declare Function RegQueryValueExLong Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Long, lpcbData As Long) As Long
Public Declare Function RegQueryValueExString Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long
Public Declare Function RegSetValueExLong Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpValue As Long, ByVal cbData As Long) As Long
Public Declare Function RegSetValueExString Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpValue As String, ByVal cbData As Long) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public 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
Public Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Public Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) As Long
Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long

Private Declare Function RegQueryInfoKey Lib "advapi32.dll" Alias "RegQueryInfoKeyA" (ByVal hKey As Long, ByVal lpClass As String, lpcbClass As Long, ByVal lpReserved As Long, lpcSubKeys As Long, lpcbMaxSubKeyLen As Long, lpcbMaxClassLen As Long, lpcValues As Long, lpcbMaxValueNameLen As Long, lpcbMaxValueLen As Long, lpcbSecurityDescriptor As Long, lpftLastWriteTime As Long) As Long
Private Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, lpcbValueName As Long, ByVal lpReserved As Long, lpType As Long, lpData As Byte, lpcbData As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, ByRef lpType As Long, ByVal lpData As String, ByRef lpcbData As Long) As Long

Private Type ByteArray
  FirstByte As Byte
  ByteBuffer(255) As Byte
End Type

Dim baData As ByteArray

'Public Declare Function RegisterTray Lib "tray.dll" (ByVal hInst As Long, ByVal trayXpos As Long, ByVal trayYpos As Long, ByVal trayHeight As Long, ByVal useEmptyTray As Long, ByVal autoHiding As Long) As Long

Public Const SND_ASYNC = &H1
Public Const SND_LOOP = &H8
Public Const conHwndTopmost = -1
Public Const conHwndNoTopmost = -2
Public Const conSwpNoActivate = &H10
Public Const conSwpShowWindow = &H40
Public Const ERROR_BADKEY = 2
Public Const ERROR_NONE = 0
Public Const EWX_LogOff As Long = 0
Public Const EWX_SHUTDOWN As Long = 1
Public Const EWX_REBOOT As Long = 2
Public Const EWX_FORCE As Long = 4
Public Const EWX_POWEROFF As Long = 8
Public Const GW_HWNDFIRST = 0
Public Const GW_HWNDNEXT = 2
Public Const GWL_EXSTYLE = (-20)
Public Const GWL_HWNDPARENT = (-8)
Public Const GWL_STYLE = (-16)
Public Const HKEY_CLASSES_ROOT = &H80000000
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const HKEY_USERS = &H80000003
Public Const HWND_TOP = 0
Public Const KEY_ALL_ACCESS = &H3F
Public Const MAX_PATH = 256
Public Const mlngWindows95 = 0
Public Const mlngWindowsNT = 1
Public Const PIE = 3.14159265
Public Const REG_SZ As Long = 1
Public Const REG_DWORD As Long = 4
Public Const SC_SCREENSAVE = &HF140&
Public Const SPI_SETWORKAREA = 47
Public Const SPI_GETWORKAREA = 48
Public Const SPIF_SENDCHANGE = &H2
Public Const SW_MAXIMIZE = 3
Public Const SW_RESTORE = 9
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOMOVE = &H2
Public Const SWP_SHOWWINDOW = &H40
Public Const WM_SYSCOMMAND = &H112&
Public Const WS_VISIBLE = &H10000000
Public Const WS_BORDER = &H800000
Public Const WS_EX_TOOLWINDOW = &H80
Public Const WS_MINIMIZE = &H20000000

Private Const KEY_QUERY_VALUE = &H1

Enum ValKey
    Values = 0
    Keys = 1
End Enum

Public Type LUID
    UsedPart As Long
    IgnoredForNowHigh32BitPart As Long
End Type
      
Public Type LUID_AND_ATTRIBUTES
    TheLuid As LUID
    Attributes As Long
End Type
      
Public Type OSVERSIONINFO
    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128
End Type
         
Public Type POINTAPI
    x As Long
    y As Long
End Type

Public Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

Private Type TOKEN_PRIVILEGES
    PrivilegeCount As Long
    TheLuid As LUID
    Attributes As Long
End Type

Public Type typeColors
    Black As ColorConstants
    Geel As ColorConstants
    Paars As ColorConstants
    Donkerblauw As ColorConstants
    Bruin As ColorConstants
    Lichtgeel As ColorConstants
    Lichtblauw As ColorConstants
    Lichtoranje As ColorConstants
    Donkerpaars As ColorConstants
    Oranje As ColorConstants
    Roze As ColorConstants
    MouseOver As ColorConstants
    White As ColorConstants
    StartMenu As ColorConstants
    SpecialA As ColorConstants
    SpecialB As ColorConstants
End Type

Type typeConfig
    AlwaysOnTop As Boolean
    Animate As Boolean
    AnimateStartMenu As Boolean
    BigSmall As Boolean
    CustomA As String
    CustomB As String
    CustomC As String
    CustomD As String
    DateTime As Boolean
    Debug As Boolean
    Desktop As String
    DesktopResize As Boolean
    DualScreen As Boolean
    EngRoom As String
    Explore As String
    Explorer As String
    IniFile As String
    LangDir As String
    Padd As String
    Password As String
    PlayBackGroundSound As Boolean
    RootDir As String
    ShellReplacement As Boolean
    Science As String
    ScreenHeight As Long
    ScreenLeft As Long
    ScreenTop As Long
    ScreenWidth As Long
    Security As String
    Sound As Boolean
    Taskbar As Boolean
End Type

Type typeSecurity
    butAbout As Boolean
    butLock As Boolean
    butQuit As Boolean
    butSecurity As Boolean
End Type

Type typeSound
    BackGroundSound As String
End Type

Public Type TypeText
    textA As String
    textB As String
    textC As String
    textD As String
    textE As String
    textF As String
    textG As String
    textH As String
    textI As String
    textJ As String
    textK As String
    textL As String
    textM As String
    textN As String
    textO As String
    textP As String
    textQ As String
    textR As String
    textS As String
    textT As String
End Type

Public dY As Integer
Public dx As Integer
Public glngWhichWindows32 As Long
Public iniValue As Variant
Public intCurrentScreen As Integer
Public myColors As typeColors
Public myConfig As typeConfig
Public myDesktop As RECT
Public myRequester As Integer
Public mySecurity As typeSecurity
Public mySound As typeSound
Public myText As TypeText
Public InputBack As String
Public InputMode As Integer
Public InputTitel As String


Public Sub AdjustToken()
    '********************************************************************
    '* This procedure sets the proper privileges to allow a log off or a
    '* shut down to occur under Windows NT.
    '********************************************************************

    Const TOKEN_ADJUST_PRIVILEGES = &H20
    Const TOKEN_QUERY = &H8
    Const SE_PRIVILEGE_ENABLED = &H2

    Dim hdlProcessHandle As Long
    Dim hdlTokenHandle As Long
    Dim tmpLuid As LUID
    Dim tkp As TOKEN_PRIVILEGES
    Dim tkpNewButIgnored As TOKEN_PRIVILEGES
    Dim lBufferNeeded As Long

    'Set the error code of the last thread to zero using the
    'SetLast Error function. Do this so that the GetLastError
    'function does not return a value other than zero for no
    'apparent reason.
    SetLastError 0

    'Use the GetCurrentProcess function to set the hdlProcessHandle
    'variable.
    hdlProcessHandle = GetCurrentProcess()
    
    OpenProcessToken hdlProcessHandle, (TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY), hdlTokenHandle

    'Get the LUID for shutdown privilege
    LookupPrivilegeValue "", "SeShutdownPrivilege", tmpLuid
    
    tkp.PrivilegeCount = 1    ' One privilege to set
    tkp.TheLuid = tmpLuid
    tkp.Attributes = SE_PRIVILEGE_ENABLED

    'Enable the shutdown privilege in the access token of this process
    AdjustTokenPrivileges hdlTokenHandle, False, tkp, Len(tkpNewButIgnored), tkpNewButIgnored, lBufferNeeded
    
End Sub

Public Function CheckShareware() As String
    '0 = Unregistered
    '1 = Registered version
    Dim fileName As String
    Dim fileSize As Long
    
    Dim filenumber
    Dim Regel As String
    Dim keyNumber As String
    Dim keyLength As String
    Dim KeyName As String
    Dim keyReal As String
    Dim userKey As Integer
    Dim Iloop As Long
    
    fileName = myConfig.RootDir & "key"
    fileSize = 0
    On Error Resume Next
    fileSize = FileLen(fileName)

    If fileSize > 0 Then
        filenumber = FreeFile
        Open fileName For Input As #filenumber
        Line Input #filenumber, Regel
        RegisteredEM = Mid(Regel, "10", "14")
        Line Input #filenumber, Regel
        keyNumber = Mid$(Regel, 15, 1) + Mid$(Regel, 30, 1) + Mid$(Regel, 45, 1) + Mid$(Regel, 60, 1)
        Line Input #filenumber, Regel
        Line Input #filenumber, Regel
        Line Input #filenumber, Regel
        Line Input #filenumber, Regel
        Line Input #filenumber, Regel
        Line Input #filenumber, Regel
        Line Input #filenumber, Regel
        Line Input #filenumber, Regel
        Line Input #filenumber, Regel
        Line Input #filenumber, Regel

        Line Input #filenumber, Regel
        keyLength = Mid$(Regel, 15, 1) + Mid$(Regel, 30, 1) + Mid$(Regel, 45, 1) + Mid$(Regel, 60, 1)

        KeyName = ""
        For Iloop = 0 To (Val(keyLength) \ 4)
            Line Input #filenumber, Regel
            KeyName = KeyName + Mid$(Regel, 15, 1) + Mid$(Regel, 30, 1) + Mid$(Regel, 45, 1) + Mid$(Regel, 60, 1)
        Next

        KeyName = Left(KeyName, Val(keyLength))

        keyReal = ""
        For Iloop = 1 To (Len(KeyName) / 3)
            keyReal = keyReal & Chr(Val(Mid(KeyName, (Iloop * 3) - 2, 3)))
        Next

        userKey = Val("1" + "2" + "3" + "4")
        For Iloop = 1 To (Len(keyReal) - 1)
            userKey = userKey + (217 - Asc(Mid(keyReal, Iloop, 1)) + Asc(Mid(keyReal, Iloop + 1, 1)))
        Next

        Close #filenumber
        'If userKey = Val(keyNumber) Then
        If keyReal <> "" Then
            CheckShareware = keyReal
            Exit Function
        Else
            RegisteredEM = "00000000000000"
        End If
    End If
    CheckShareware = ""
    RegisteredEM = "00000000000000"
End Function

Public Function CheckFile(strFile As String) As Boolean
    Dim fileSize As Long
    
    fileSize = 0
    On Error Resume Next
    fileSize = FileLen(strFile)
    On Error GoTo 0
    If fileSize > 0 Then
        CheckFile = True
    Else
        CheckFile = False
    End If
End Function

Public Sub Draw_Text(dform As Form, dx As Integer, dY As Integer, dWidth As Integer, dHeight As Integer, dColor As ColorConstants, dText As String, dMode As Integer)
    dform.FontName = "Haettenschweiler"
    dform.FontSize = 2
    dform.FontBold = False
    dform.FontItalic = False
    dform.FontStrikethru = False
    dform.FontUnderline = False
    While (dform.TextHeight(dText) < dHeight) And (dform.TextWidth(dText) < dWidth)
        dform.FontSize = dform.FontSize + 1
    Wend
    If (dMode = vbLeftJustify) Then
        dform.CurrentX = dx
    ElseIf (dMode = vbCenter) Then
        dform.CurrentX = dx + ((dx + dWidth - dform.TextWidth(dText)) / 2)
    Else
        dform.CurrentX = dx + dWidth - dform.TextWidth(dText)
    End If
    
    dform.CurrentY = dY
    dform.ForeColor = dColor
    dform.Print dText
End Sub

Public Function EnumValue(RegisteryKeyHandle As Long, KeyIndex As Long) As String
    Dim lBufferLen As Long, i As Integer
    Dim lValNameLen As Long
    Dim lValLen As Long
    
    For i = 0 To 255
      baData.ByteBuffer(i) = 0
    Next
    lBufferLen = 255
    EnumValue = Space(MAX_PATH + 1)
    RegQueryInfoKey RegisteryKeyHandle, "", 0, 0, 0, 0, 0, 0, lValNameLen, lValLen, 0, 0
    RegEnumValue RegisteryKeyHandle, KeyIndex, EnumValue, MAX_PATH + 1, 0, 0, baData.FirstByte, lBufferLen
    EnumValue = Trim(EnumValue)
End Function

Public Function GetCount(RegisteryKeyHandle As Long, ValuesOrKeys As ValKey) As Long
    If ValuesOrKeys = Keys Then RegQueryInfoKey RegisteryKeyHandle, "", 0, 0, GetCount, 0, 0, 0, 0, 0, 0, 0
    If ValuesOrKeys = Values Then RegQueryInfoKey RegisteryKeyHandle, "", 0, 0, 0, 0, 0, GetCount, 0, MAX_PATH + 1, 0, 0
End Function

Public Function GetKeyValue(hKey As Long, KeyName As String) As String
    Dim i As Long                                           ' Loop Counter
    Dim rc As Long                                          ' Return Code
    
    Dim hDepth As Long                                      '
    Dim sKeyVal As String
    Dim lKeyValType As Long                                 ' Data Type Of A Registry Key
    Dim tmpVal As String                                    ' Tempory Storage For A Registry Key Value
    Dim KeyValSize As Long                                  ' Size Of Registry Key Variable
    
    tmpVal = String$(1024, 0)                             ' Allocate Variable Space
    KeyValSize = 1024                                       ' Mark Variable Size
    
    '------------------------------------------------------------
    ' Retrieve Registry Key Value...
    '------------------------------------------------------------
    rc = RegQueryValueEx(hKey, KeyName, 0, _
                         lKeyValType, tmpVal, KeyValSize)
    GetKeyValue = Trim(tmpVal)
End Function

Public Function getVersion() As Integer
    Dim osinfo As OSVERSIONINFO
    Dim retvalue As Integer

    osinfo.dwOSVersionInfoSize = 148
    osinfo.szCSDVersion = Space$(128)
    retvalue = GetVersionExA(osinfo)

    getVersion = osinfo.dwPlatformId
End Function

Public Function INI_GetKey(SectionName As String, KeyName As String, IniFileName As String) As Boolean
    Dim ReturnString As String
    Dim ReturnValue As Long
    
    On Local Error GoTo GetKey_Err
    ReturnString = String$(32000, 0)
    iniValue = ""
    ReturnValue = GetPrivateProfileString(SectionName & Chr(0), KeyName, "NotFound", ReturnString, Len(ReturnString), IniFileName & Chr(0))
    If Left(ReturnString, InStr(ReturnString, Chr$(0)) - 1) = "NotFound" Then
        INI_GetKey = False
    Else
        INI_GetKey = True
        iniValue = Left(ReturnString, InStr(ReturnString, Chr$(0)) - 1)
    End If

GetKey_End:
    Exit Function

GetKey_Err:
    MsgBox "Error Retrieving Key"
    INI_GetKey = False
    Resume GetKey_End
End Function

Public Function INI_WriteKey(SectionName As String, KeyName As String, KeyValue As String, IniFileName As String)
    On Local Error GoTo WriteKey_Err
    iniValue = ""
    INI_WriteKey = WritePrivateProfileString(SectionName, KeyName, KeyValue, IniFileName)

WriteKey_End:
    Exit Function

WriteKey_Err:
    MsgBox "Error Writing Key"
    INI_WriteKey = False
    Resume WriteKey_End
End Function

Public Sub Init()
End Sub

Public Function IsToolWindow(ByVal hwnd As Long) As Boolean
   ' Check for toolwindow style bit.
   IsToolWindow = ((GetWindowLong(hwnd, GWL_EXSTYLE) And WS_EX_TOOLWINDOW) = WS_EX_TOOLWINDOW)
End Function

Public Sub MOUSE_Check()
End Sub

Public Function MOUSE_GetX() As Long
    Dim mouseco As POINTAPI
    
    GetCursorPos mouseco
    MOUSE_GetX = mouseco.x
End Function

Public Function MOUSE_GetY() As Long
    Dim mousecp As POINTAPI
    
    GetCursorPos mousecp
    MOUSE_GetY = mousecp.y
End Function

Public Function OpenKey(RegistryKey As Long, Optional SubKey As String) As Long
    If OpenKey <> 0 Then RegCloseKey (OpenKey)
    RegOpenKeyEx RegistryKey, SubKey, 0, KEY_QUERY_VALUE, OpenKey
End Function

Private Function QueryValueEx(ByVal lhKey As Long, ByVal szValueName As String, vValue As Variant) As Long
    Dim cch As Long
    Dim lrc As Long
    Dim lType As Long
    Dim lValue As Long
    Dim sValue As String
    
    On Error GoTo QueryValueExError
    
    ' Determine the size and type of data to be read
    lrc = RegQueryValueExNULL(lhKey, szValueName, 0&, lType, 0&, cch)
    If lrc <> ERROR_NONE Then Error 5
    
    Select Case lType
        ' For strings
        Case REG_SZ:
            sValue = String(cch, 0)
            lrc = RegQueryValueExString(lhKey, szValueName, 0&, lType, sValue, cch)
            If lrc = ERROR_NONE Then
                vValue = Left$(sValue, cch - 1)
            Else
                vValue = Empty
            End If
        ' For DWORDS
        Case REG_DWORD, 3:
            lrc = RegQueryValueExLong(lhKey, szValueName, 0&, lType, lValue, cch)
            If lrc = ERROR_NONE Then vValue = lValue
        Case Else
        'all other data types not supported
        lrc = -1
    End Select
    
QueryValueExExit:
    QueryValueEx = lrc
    Exit Function
QueryValueExError:
    Resume QueryValueExExit
End Function


Public Function RegistryGet(sKeyName As String, sValueName As String, lPredefinedKey As Long) As String
    Dim lRetVal As Long         'result of the API functions
    Dim hKey As Long         'handle of opened key
    Dim vValue As Variant      'setting of queried value
    
    lRetVal = RegOpenKeyEx(lPredefinedKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)
    lRetVal = QueryValueEx(hKey, sValueName, vValue)
    RegCloseKey (hKey)
    If lRetVal = ERROR_BADKEY Then
        RegistryGet = ""
    Else
        RegistryGet = vValue
    End If
End Function

Public Sub RegistrySet(sKeyName As String, sValueName As String, vValueSetting As Variant, lValueType As Long)
       Dim lRetVal As Long         'result of the SetValueEx function
       Dim hKey As Long         'handle of open key

       'open the specified key
       lRetVal = RegOpenKeyEx(HKEY_CURRENT_USER, sKeyName, 0, _
                              KEY_ALL_ACCESS, hKey)
       lRetVal = SetValueEx(hKey, sValueName, lValueType, vValueSetting)
       RegCloseKey (hKey)
End Sub

Private Function SetValueEx(ByVal hKey As Long, sValueName As String, _
   lType As Long, vValue As Variant) As Long
       Dim lValue As Long
       Dim sValue As String
       Select Case lType
           Case REG_SZ
               sValue = vValue & Chr$(0)
               SetValueEx = RegSetValueExString(hKey, sValueName, 0&, lType, sValue, Len(sValue))
           Case REG_DWORD
               lValue = vValue
               SetValueEx = RegSetValueExLong(hKey, sValueName, 0&, lType, lValue, 4)
           End Select
End Function

Public Function ShellFile(sfPath As String)
    On Error Resume Next
    ShellFile = ShellExecute(frmMain.hwnd, "open", sfPath, "", "", 1)
End Function

Public Function ShellReplacement()
    Dim currWnd As Long
    Dim Length As Long
    Dim listItem$
    Dim retVal As Boolean
    
    retVal = True
    currWnd = GetWindow(frmMain.hwnd, GW_HWNDFIRST)
    While currWnd <> 0
        Length = GetWindowTextLength(currWnd)
        listItem$ = Space$(Length + 1)
        Length = GetWindowText(currWnd, listItem$, Length + 1)
        If (Length > 10) Then
            If (Left(listItem$, Length) = "Program Manager") Then
                retVal = False
            End If
        End If
        currWnd = GetWindow(currWnd, GW_HWNDNEXT)
    Wend
    ShellReplacement = retVal
End Function

Public Function ShowScreen(intScreen As Integer)
    Dim tmpWidth As Integer
    'Dim tmpOffset As Integer
    'Dim tmpTaskheight As Integer
    'Dim tmpPic As String
    'Dim intButWidth As Integer
    'Dim intButHeight As Integer
    'Dim intButOffset As Integer
    
    frmMain.Image1.Picture = LoadPicture(myConfig.RootDir & "images\all-shell-doom1n.bmp")
    frmMain.Image1.Top = 65
    frmMain.Image1.Width = 95
    frmMain.Image1.Height = 25
    frmMain.Image1.Left = 0
    frmMain.picBut(5).Height = 25
    frmMain.picBut(5).Width = 70
    frmMain.picBut(5).Top = frmMain.Image1.Top - frmMain.picBut(5).Height
    frmMain.picBut(5).Left = 0
    frmMain.picBut(5).Picture = LoadPicture(myConfig.RootDir & "images\" & myConfig.LangDir & "-shell-but6n.bmp")
    frmMain.Picture1.Top = 0
    frmMain.Picture1.Left = 0
    frmMain.Picture1.Width = 70
    frmMain.Picture1.Height = frmMain.picBut(5).Top - 2 - frmMain.Picture1.Top
    frmMain.Picture1.BackColor = myColors.Paars
    tmpWidth = Int((frmMain.ScaleWidth - 125) / 20)
    frmMain.Picture3.Top = frmMain.Image1.Top + frmMain.Image1.Height - 12
    frmMain.Picture3.Left = frmMain.Image1.Left + frmMain.Image1.Width
    frmMain.Picture3.Height = 12
    frmMain.Picture3.Width = (tmpWidth * 8) - frmMain.Picture3.Left
    frmMain.Picture3.BackColor = myColors.Lichtblauw
    frmMain.Picture4.Top = frmMain.Picture3.Top
    frmMain.Picture4.Left = frmMain.Picture3.Left + frmMain.Picture3.Width + 2
    frmMain.Picture4.Height = frmMain.Picture3.Height
    frmMain.Picture4.Width = tmpWidth
    frmMain.Picture4.BackColor = myColors.Geel
    frmMain.Picture5.Height = Int(frmMain.Picture3.Height / 2)
    frmMain.Picture5.Top = frmMain.Picture3.Top + frmMain.Picture5.Height
    frmMain.Picture5.Left = frmMain.Picture4.Left + frmMain.Picture4.Width + 2
    frmMain.Picture5.Width = Int(tmpWidth * 2.5)
    frmMain.Picture5.BackColor = myColors.Donkerpaars
    frmMain.Picture6.Top = frmMain.Picture3.Top
    frmMain.Picture6.Left = frmMain.Picture5.Left + frmMain.Picture5.Width + 2
    frmMain.Picture6.Height = frmMain.Picture3.Height
    frmMain.Picture6.Width = Int(tmpWidth * 4.5)
    frmMain.Picture6.BackColor = myColors.Paars
    frmMain.Picture7.Top = frmMain.Picture3.Top
    frmMain.Picture7.Left = frmMain.Picture6.Left + frmMain.Picture6.Width + 2
    frmMain.Picture7.Height = frmMain.Picture3.Height
    frmMain.Picture7.BackColor = myColors.Paars
    frmMain.Picture8.Top = frmMain.Picture3.Top
    frmMain.Picture8.Left = frmMain.ScaleWidth - 100
    frmMain.Picture8.Height = frmMain.Picture3.Height
    frmMain.Picture8.Width = 100 'frmmain.ScaleWidth - frmmain.Picture8.Left
    frmMain.Picture8.BackColor = myColors.Donkerpaars
    frmMain.Picture7.Width = frmMain.Picture8.Left - 2 - frmMain.Picture7.Left
    If myConfig.ShellReplacement = False And myConfig.DesktopResize = False Then
        frmMain.Picture8.Picture = LoadPicture(myConfig.RootDir & "images\" & myConfig.LangDir & "-shell-but15n.bmp")
        frmMain.Picture8.Enabled = True
    Else
        frmMain.Picture8.Enabled = False
    End If
    
    frmMain.Image2.Picture = LoadPicture(myConfig.RootDir & "images\all-shell-doom2n.bmp")
    frmMain.Image2.Top = frmMain.Image1.Top + frmMain.Image1.Height + 5
    frmMain.Image2.Width = 95
    frmMain.Image2.Height = 25
    frmMain.Image2.Left = 0
    frmMain.Picture9.Top = frmMain.Image2.Top
    frmMain.Picture9.Left = frmMain.Picture8.Left
    frmMain.Picture9.Height = 12
    frmMain.Picture9.Width = frmMain.Picture8.Width
    frmMain.Picture9.BackColor = myColors.Geel
    frmMain.Picture10.Top = frmMain.Image2.Top
    frmMain.Picture10.Left = frmMain.Picture7.Left
    frmMain.Picture10.Height = frmMain.Picture9.Height
    frmMain.Picture10.Width = frmMain.Picture7.Width
    frmMain.Picture10.BackColor = myColors.Roze
    frmMain.Picture11.Top = frmMain.Image2.Top
    frmMain.Picture11.Left = frmMain.Picture5.Left + frmMain.Picture5.Width + 2
    frmMain.Picture11.Height = frmMain.Picture9.Height
    frmMain.Picture11.Width = Int(tmpWidth * 4.5)
    frmMain.Picture11.BackColor = myColors.Roze
    frmMain.Picture12.Top = frmMain.Image2.Top
    frmMain.Picture12.Left = frmMain.Picture4.Left + frmMain.Picture4.Width + 2
    frmMain.Picture12.Height = Int(frmMain.Picture9.Height / 2)
    frmMain.Picture12.Width = Int(tmpWidth * 2.5)
    frmMain.Picture12.BackColor = myColors.Geel
    frmMain.Picture13.Top = frmMain.Image2.Top
    frmMain.Picture13.Left = frmMain.Picture3.Left + frmMain.Picture3.Width + 2
    frmMain.Picture13.Height = frmMain.Picture9.Height
    frmMain.Picture13.Width = tmpWidth
    frmMain.Picture13.BackColor = myColors.Lichtgeel
    frmMain.Picture14.Top = frmMain.Image2.Top
    frmMain.Picture14.Left = frmMain.Image2.Left + frmMain.Image2.Width
    frmMain.Picture14.Height = frmMain.Picture9.Height
    frmMain.Picture14.Width = (tmpWidth * 8) - frmMain.Picture14.Left
    frmMain.Picture14.BackColor = myColors.Donkerpaars
    
    frmMain.picBut(4).Top = frmMain.Image2.Top + frmMain.Image2.Height
    frmMain.picBut(4).Left = 0
    frmMain.picBut(4).Picture = LoadPicture(myConfig.RootDir & "images\" & myConfig.LangDir & "-shell-but5n.bmp")
    frmMain.picBut(4).Height = 25
    frmMain.picBut(4).Width = 70
    frmMain.picBut(6).Top = frmMain.picBut(4).Top + frmMain.picBut(4).Height + 2
    frmMain.picBut(6).Left = 0
    frmMain.picBut(6).Picture = LoadPicture(myConfig.RootDir & "images\" & myConfig.LangDir & "-shell-but7n.bmp")
    frmMain.picBut(6).Height = 50
    frmMain.picBut(6).Width = 70
    frmMain.picBut(7).Top = frmMain.picBut(6).Top + frmMain.picBut(6).Height + 2
    frmMain.picBut(7).Left = 0
    frmMain.picBut(7).Picture = LoadPicture(myConfig.RootDir & "images\" & myConfig.LangDir & "-shell-but8n.bmp")
    frmMain.picBut(7).Height = 25
    frmMain.picBut(7).Width = 70
    frmMain.picBut(8).Top = frmMain.picBut(7).Top + frmMain.picBut(7).Height + 2
    frmMain.picBut(8).Left = 0
    frmMain.picBut(8).Picture = LoadPicture(myConfig.RootDir & "images\" & myConfig.LangDir & "-shell-but9n.bmp")
    frmMain.picBut(8).Height = 25
    frmMain.picBut(8).Width = 70
    frmMain.picBut(9).Top = frmMain.picBut(8).Top + frmMain.picBut(8).Height + 2
    frmMain.picBut(9).Left = 0
    frmMain.picBut(9).Picture = LoadPicture(myConfig.RootDir & "images\" & myConfig.LangDir & "-shell-but10n.bmp")
    frmMain.picBut(9).Height = 25
    frmMain.picBut(9).Width = 70
    frmMain.picBut(14).Top = frmMain.picBut(9).Top + frmMain.picBut(9).Height + 2
    frmMain.picBut(14).Left = 0
    frmMain.picBut(14).Picture = LoadPicture(myConfig.RootDir & "images\" & myConfig.LangDir & "-shell-but11n.bmp")
    frmMain.picBut(14).Height = 25
    frmMain.picBut(14).Width = 70
    frmMain.picBut(15).Top = frmMain.picBut(14).Top + frmMain.picBut(14).Height + 2
    frmMain.picBut(15).Left = 0
    frmMain.picBut(15).Picture = LoadPicture(myConfig.RootDir & "images\" & myConfig.LangDir & "-shell-but12n.bmp")
    frmMain.picBut(15).Height = 25
    frmMain.picBut(15).Width = 70
    frmMain.picBut(16).Top = frmMain.picBut(15).Top + frmMain.picBut(15).Height + 2
    frmMain.picBut(16).Left = 0
    frmMain.picBut(16).Picture = LoadPicture(myConfig.RootDir & "images\" & myConfig.LangDir & "-shell-but13n.bmp")
    frmMain.picBut(16).Height = 25
    frmMain.picBut(16).Width = 70
    frmMain.picBut(17).Top = frmMain.picBut(16).Top + frmMain.picBut(16).Height + 2
    frmMain.picBut(17).Left = 0
    frmMain.picBut(17).Picture = LoadPicture(myConfig.RootDir & "images\" & myConfig.LangDir & "-shell-but14n.bmp")
    frmMain.picBut(17).Height = 25
    frmMain.picBut(17).Width = 70
    
    If myConfig.Taskbar = True And ShellReplacement = False Then
        frmMain.Image3.Picture = LoadPicture(myConfig.RootDir & "images\all-shell-doom3n.bmp")
        frmMain.Image3.Top = frmMain.ScaleHeight - 50
        frmMain.Image3.Width = 95
        frmMain.Image3.Height = 25
        frmMain.Image3.Left = 0
        frmMain.Image4.Picture = LoadPicture(myConfig.RootDir & "images\all-shell-taskbar.bmp")
        frmMain.Image4.Top = frmMain.Image3.Top + frmMain.Image3.Height - 12
        frmMain.Image4.Width = 95
        frmMain.Image4.Height = 47
        frmMain.Image4.Left = frmMain.ScaleWidth - frmMain.Image4.Width
        frmMain.Picture15.Top = frmMain.Image4.Top
        frmMain.Picture15.Left = frmMain.Image3.Left + frmMain.Image3.Width
        frmMain.Picture15.Height = 12
        frmMain.Picture15.Width = (tmpWidth * 8) - frmMain.Picture15.Left
        frmMain.Picture15.BackColor = myColors.Geel
        frmMain.Picture2.Top = frmMain.picBut(17).Top + frmMain.picBut(17).Height + 2
        frmMain.Picture2.Left = 0
        frmMain.Picture2.Height = frmMain.Image3.Top - 2 - frmMain.Picture2.Top
        frmMain.Picture2.Width = 70
        frmMain.Picture2.BackColor = myColors.Geel
        frmMain.Picture17.Top = frmMain.Picture15.Top
        frmMain.Picture17.Left = frmMain.Picture15.Left + frmMain.Picture15.Width + 2
        frmMain.Picture17.Height = frmMain.Picture15.Height
        frmMain.Picture17.Width = tmpWidth
        frmMain.Picture17.BackColor = myColors.Roze
        frmMain.Picture18.Top = frmMain.Picture15.Top
        frmMain.Picture18.Left = frmMain.Picture17.Left + frmMain.Picture17.Width + 2
        frmMain.Picture18.Height = Int(frmMain.Picture15.Height / 2)
        frmMain.Picture18.Width = Int(tmpWidth * 2.5)
        frmMain.Picture18.BackColor = myColors.Donkerpaars
        frmMain.Picture19.Top = frmMain.Picture15.Top
        frmMain.Picture19.Left = frmMain.Picture18.Left + frmMain.Picture18.Width + 2
        frmMain.Picture19.Height = frmMain.Picture15.Height
        frmMain.Picture19.Width = Int(tmpWidth * 4.5)
        frmMain.Picture19.BackColor = myColors.Paars
        frmMain.Picture20.Top = frmMain.Picture15.Top
        frmMain.Picture20.Left = frmMain.Picture19.Left + frmMain.Picture19.Width + 2
        frmMain.Picture20.Height = frmMain.Picture15.Height
        frmMain.Picture20.Width = frmMain.Image4.Left - frmMain.Picture20.Left
        frmMain.Picture20.BackColor = myColors.Lichtblauw
                    
        frmMain.lblTime.Left = frmMain.ScaleWidth - 80
        frmMain.lblTime.Width = 75
        frmMain.lblTime.Top = frmMain.ScaleHeight - 20
        frmMain.lblTime.Height = 20
        frmMain.lblTime.ForeColor = myColors.Black
        frmMain.lblTime.Caption = ""
        frmMain.lblTime.Alignment = 1
        frmMain.lblTime.FontName = "Haettenschweiler"
        frmMain.lblTime.FontSize = "10"
    Else
        frmMain.Picture2.Top = frmMain.picBut(17).Top + frmMain.picBut(17).Height + 2
        frmMain.Picture2.Left = 0
        frmMain.Picture2.Height = frmMain.ScaleHeight - 2 - frmMain.Picture2.Top
        frmMain.Picture2.Width = 70
        frmMain.Picture2.BackColor = myColors.Geel
    End If
                
                
    frmMain.picBut(0).Top = frmMain.Picture8.Top - 48
    frmMain.picBut(0).Left = frmMain.ScaleWidth - 244
    frmMain.picBut(0).Height = 20
    frmMain.picBut(0).Width = 120
    frmMain.picBut(0).Picture = LoadPicture(myConfig.RootDir & "images\" & myConfig.LangDir & "-shell-but1n.bmp")
    frmMain.picBut(1).Top = frmMain.picBut(0).Top
    frmMain.picBut(1).Left = frmMain.ScaleWidth - 120
    frmMain.picBut(1).Height = 20
    frmMain.picBut(1).Width = 120
    frmMain.picBut(1).Picture = LoadPicture(myConfig.RootDir & "images\" & myConfig.LangDir & "-shell-but2n.bmp")
    frmMain.picBut(2).Top = frmMain.picBut(0).Top + 24
    frmMain.picBut(2).Left = frmMain.ScaleWidth - 244
    frmMain.picBut(2).Height = 20
    frmMain.picBut(2).Width = 120
    frmMain.picBut(2).Picture = LoadPicture(myConfig.RootDir & "images\" & myConfig.LangDir & "-shell-but3n.bmp")
    frmMain.picBut(3).Top = frmMain.picBut(0).Top + 24
    frmMain.picBut(3).Left = frmMain.ScaleWidth - 120
    frmMain.picBut(3).Height = 20
    frmMain.picBut(3).Width = 120
    frmMain.picBut(3).Picture = LoadPicture(myConfig.RootDir & "images\" & myConfig.LangDir & "-shell-but4n.bmp")
                
    frmMain.picBut(10).Top = frmMain.ScaleHeight - 20
    frmMain.picBut(10).Left = 0
    frmMain.picBut(10).Height = 18
    frmMain.picBut(10).Width = 70
    frmMain.picBut(10).Picture = LoadPicture(myConfig.RootDir & "images\" & myConfig.LangDir & "-shell-taskbar-1n.bmp")
    frmMain.picBut(11).Top = frmMain.ScaleHeight - 20
    frmMain.picBut(11).Left = 75
    frmMain.picBut(11).Height = 18
    frmMain.picBut(11).Width = 70
    frmMain.picBut(11).Picture = LoadPicture(myConfig.RootDir & "images\" & myConfig.LangDir & "-shell-taskbar-2n.bmp")
    frmMain.picBut(12).Top = frmMain.ScaleHeight - 20
    frmMain.picBut(12).Left = 150
    frmMain.picBut(12).Height = 18
    frmMain.picBut(12).Width = 70
    frmMain.picBut(12).Picture = LoadPicture(myConfig.RootDir & "images\" & myConfig.LangDir & "-shell-taskbar-3n.bmp")
    frmMain.picBut(13).Top = frmMain.ScaleHeight - 20
    frmMain.picBut(13).Left = 225
    frmMain.picBut(13).Height = 18
    frmMain.picBut(13).Width = 70
    frmMain.picBut(13).Picture = LoadPicture(myConfig.RootDir & "images\" & myConfig.LangDir & "-shell-taskbar-4n.bmp")
                
                
    frmMain.Picture1.Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.picBut(5).Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.Image1.Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.Picture3.Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.Picture4.Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.Picture5.Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.Picture6.Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.Picture7.Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.Picture8.Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)

    frmMain.Picture9.Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.Picture10.Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.Picture11.Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.Picture12.Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.Picture13.Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.Picture14.Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.Image2.Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.picBut(4).Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.picBut(6).Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.picBut(7).Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.picBut(8).Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.picBut(9).Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.picBut(14).Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.picBut(15).Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.picBut(16).Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.picBut(17).Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    
    frmMain.Picture2.Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.Image3.Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.Picture15.Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.Picture17.Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.Picture18.Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.Picture19.Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.Picture20.Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)

    frmMain.Image4.Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.lblTime.Visible = True



    Draw_Text frmMain, frmMain.ScaleWidth / 2, -3, frmMain.ScaleWidth / 2, 30, myColors.Geel, "LCARS TERMINAL", vbAlignRight
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.picBut(0).Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.picBut(1).Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.picBut(2).Visible = True
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
    frmMain.picBut(3).Visible = True
    DoEvents
    If myConfig.Taskbar = True And ShellReplacement = False Then
        If myConfig.Animate = True Then Sleep (100)
        frmMain.picBut(10).Visible = True
        DoEvents
        If myConfig.Animate = True Then Sleep (100)
        frmMain.picBut(11).Visible = True
        DoEvents
        If myConfig.Animate = True Then Sleep (100)
        frmMain.picBut(12).Visible = True
        DoEvents
        If myConfig.Animate = True Then Sleep (100)
        frmMain.picBut(13).Visible = True
        DoEvents
    End If
    If myConfig.Animate = True Then Sleep (100)
    DoEvents
    If myConfig.Animate = True Then Sleep (100)
End Function

Public Sub Startup_Start()
    Dim hKey As Long
    Dim strStartup As String
    Dim lngLoop As Long
    
    On Error Resume Next
    strStartup = RegistryGet("Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "Startup", HKEY_CURRENT_USER)
    frmMain.fileStartup.Path = strStartup
    For lngLoop = 0 To frmMain.fileStartup.ListCount - 1
        ShellFile strStartup & "\" & frmMain.fileStartup.List(lngLoop)
    Next
End Sub

Public Sub SystemTray_Start()
    Dim hKey As Long
    Dim Values As ValKey
    Dim lCount As Long
    Dim i As Long
    
    On Error Resume Next
    
    frmMain.lstStartup.Clear
    hKey = OpenKey(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run")
    lCount = GetCount(hKey, Values)
    For i = 0 To lCount - 1
        frmMain.lstStartup.AddItem GetKeyValue(hKey, EnumValue(hKey, i))
    Next i
    
    hKey = OpenKey(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\RunServices")
    lCount = GetCount(hKey, Values)
    For i = 0 To lCount - 1
        frmMain.lstStartup.AddItem GetKeyValue(hKey, EnumValue(hKey, i))
    Next i
    
    hKey = OpenKey(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Run")
    lCount = GetCount(hKey, Values)
    For i = 0 To lCount - 1
        frmMain.lstStartup.AddItem GetKeyValue(hKey, EnumValue(hKey, i))
    Next i
    
    For i = 0 To frmMain.lstStartup.ListCount - 1
        Shell frmMain.lstStartup.List(i), vbNormalFocus
    Next
End Sub

Public Sub TaskList_Get()
    Dim lngStyle As Long
    Dim Addcounter As Integer
    Dim tempcheck As String
    Dim currWnd As Long
    Dim Length As Long
    Dim listItem$
    Dim IsTask As Long
    
    
    IsTask = WS_VISIBLE Or WS_BORDER
    
    frmFastRun.List1.Clear
    currWnd = GetWindow(frmMain.hwnd, GW_HWNDFIRST)
    While currWnd <> 0
        If IsWindowVisible(currWnd) Then
            If GetParent(currWnd) = 0 Then
                lngStyle = GetWindowLong(currWnd, GWL_HWNDPARENT)
                If (lngStyle = 0) Or IsToolWindow(lngStyle) Then
                    If Not IsToolWindow(currWnd) Then
                        Length = GetWindowTextLength(currWnd)
                        listItem$ = Space$(Length + 1)
                        Length = GetWindowText(currWnd, listItem$, Length + 1)
                        frmFastRun.List1.AddItem (CStr(currWnd) & "|" & listItem$)
                    End If
                End If
            End If
        End If
                
        'Length = GetWindowTextLength(currWnd)
        'listItem$ = Space$(Length + 1)
        'Length = GetWindowText(currWnd, listItem$, Length + 1)
        'lngStyle = GetWindowLong(currWnd, GWL_STYLE)
        'tempcheck = ""
        'If Length > 6 Then
        '    tempcheck = UCase(Left(listItem$, 6))
        'End If
        'If tempcheck = "LCARS " Then
        '    'Doe niets
        'Else
        '    If Len(listItem$) > 60 Then
        '        listItem$ = Left(listItem$, 58) & ".."
        '    End If
        '    If Length > 0 Then
        '        If (lngStyle And IsTask) = IsTask Then
        '            If GetParent(currWnd) = 0 Then
        '                frmFastRun.List1.AddItem (CStr(currWnd) & "|" & listItem$)
        '            End If
        '        Else
        '            'Controleren of winamp misschien ook ergens
        '            'in het geheugen zit natuurlijk
        '            'Controle op in taskbar, in systemtray of gewoon open!
        '            If (lngStyle = 604635136) Or (lngStyle = 336199680) Or (lngStyle = 873070592) Then
        '                frmFastRun.List1.AddItem (CStr(currWnd) & "|" & listItem$)
        '            End If
        '        End If
        '    End If
        'End If
        currWnd = GetWindow(currWnd, GW_HWNDNEXT)
    Wend
End Sub
