Attribute VB_Name = "mod_Global"
Option Explicit

Public parent As Long
Public SysBox As Long
Public SysSize As RECT
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Public Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Public Declare Sub GetWindowRect Lib "User" (ByVal hWnd As Integer, lpRect As RECT)
Public Declare Function GetClientRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
Private 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
Public booVoice As Boolean

Public Type OSVERSIONINFO '
   dwOSVersionInfoSize As Long
   dwMajorVersion As Long
   dwMinorVersion As Long
   dwBuildNumber As Long
   dwPlatformId As Long           '1 = Windows 95/98
                                  '2 = Windows NT
   szCSDVersion As String * 128
End Type
Public Const VER_PLATFORM_WIN32_NT = 2
Public Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Integer

Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32.dll" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Public Const WS_EX_LAYERED = &H80000
Public Const LWA_COLORKEY = &H1

Public Const SWP_HIDEWINDOW = &H80
Private Const SWP_NOZORDER     As Long = &H4
Private Const SWP_FRAMECHANGED As Long = &H20
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Private Const SWP_REFRESH      As Long = SWP_NOSIZE Or _
                                        SWP_NOMOVE Or _
                                        SWP_NOZORDER Or _
                                        SWP_FRAMECHANGED

Private Const TVM_SETBKCOLOR = 4381&
Private Const TVM_GETBKCOLOR = 4383&
Public Const SW_SHOW = 5
Public Const SW_HIDE = 0

Public shellRep As Boolean

Private Const HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1
Public Const MAX_PATH = 256

Public Const GWL_STYLE = (-16)
Public Const WS_MINIMIZE = &H20000000
Public Const SW_MAXIMIZE = 3
Public Const HWND_TOP = 0
Public Const SWP_SHOWWINDOW = &H40
Public Const SW_RESTORE = 9
Private Const KEY_QUERY_VALUE = &H1
Public Const SPI_SETWORKAREA = 47
Public Const SPIF_SENDCHANGE = &H2
Public Const SPIF_SENDWININICHANGE = &H2
Public Const SPIF_UPDATEINIFILE = &H1

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

Enum ValKey
    Values = 0
    Keys = 1
End Enum

Private Type BITMAPHEADER
    bmType As Long
    bmWidth As Long
    bmHeight As Long
    bmWidthBytes As Long
    bmPlanes As Integer
    bmbpImage As Integer
    bmBits As Long
End Type

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

Dim baData As ByteArray

Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function GetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long
Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
Public Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private 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 PlaySoundNow Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags 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 RegCloseKey Lib "advapi32.dll" (ByVal hKey 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 ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) 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
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 ReleaseCapture Lib "user32" () As Long


Public Const ERROR_BADKEY = 2
Public Const ERROR_NONE = 0
Public Const KEY_ALL_ACCESS = &H3F
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const REG_SZ As Long = 1
Public Const REG_DWORD As Long = 4

Public actionMode As String
Public iniValue As Variant
Public inputBack As String
Public inputMode As Boolean
Public mouseH As Long
Public mouseX As Long
Public mouseY As Long
Public myAnim As Boolean
Public myDebug As Boolean
Public myControls As Long
Public myPassword As String
Public mySleep As Long
Public strVolgorde As String
Public strStartRootA As String
Public strStartRootB As String
Public strStartSubdir As String

Public strTimeString As String
Public booTime As Boolean

Public myDesktopLeft As Long
Public myDesktopTop As Long

Public myButtons() As String
Public myActions() As String
Public mySndClick() As String
Public mySndOver() As String
Public mySecurity() As Long
Public myButCount As Long
Public myAnimStart() As Long
Public myAnimCurrent() As Long
Public myAnimEnd() As Long
Public myAnimCount As Long
Public myAnimFrame As Long

Public strApplication As String
Public strProgram As String
Public strProgramdir As String
Public strThemedir As String
Public strThemeName As String
Public RegisterText As String

Public Const conHwndTopmost = -1
Public Const conHwndTopNot = -2
Public Const GW_HWNDFIRST = 0
Public Const GW_HWNDNEXT = 2
Public Const GWL_EXSTYLE = (-20)
Public Const GWL_HWNDPARENT = (-8)
Public Const WS_BORDER = &H800000
Public Const WS_EX_TOOLWINDOW = &H80
Public Const WS_VISIBLE = &H10000000

Public Type POINTAPI
    X As Long
    Y As Long
End Type

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 GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
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 mciExecute& Lib "winmm.dll" (ByVal lpstrCommand As String)
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 WindowFromPoint Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long

Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Public Function Activate_Application() As Long
    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
    Dim Counting As Long
    
    Activate_Application = -1
    IsTask = WS_VISIBLE Or WS_BORDER
    
    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)
                        If (Left(listItem$, Length) = strApplication) Then
                            Activate_Application = currWnd
                       End If
                    End If
                End If
            End If
        End If
        currWnd = GetWindow(currWnd, GW_HWNDNEXT)
    Wend
End Function

Public Function Check_Shareware() As String
    Dim userSkey As Long
    Dim userLkey As Long
    Dim userXkey As Long
    Dim Skey As String
    Dim Lkey As String
    Dim Xkey As String
    Dim Cname As String
    Dim CData As String
    Dim CNaam As String
    Dim I As Long
    Dim lngCdate As Long
    Dim lngSdate As Long
    Dim lngEdate As Long
    Dim sDate
    Dim dDate
    
    Skey = GetSetting("LCARS Terminal", "Default", "Skey", "1")
    Lkey = GetSetting("LCARS Terminal", "Default", "Lkey", "1")
    Xkey = GetSetting("LCARS Terminal", "Default", "Xkey", "1")
    CNaam = GetSetting("LCARS Terminal", "Default", "Name", "1")
    CData = GetSetting("LCARS Terminal", "Default", "Date", "20010101")
    Check_Shareware = ""
    lngCdate = Val(Format(Now, "yyyymmdd"))
    lngSdate = Val(CData)
    
    Cname = Mid(CData, 7, 2) & "-" & MonthName(CLng(Mid(CData, 5, 2))) & "-" & Left(CData, 4)
    sDate = CDate(Cname)
    dDate = DateAdd("m", 12, sDate)
    lngEdate = Val(Format(dDate, "yyyymmdd"))
    Cname = CData & CNaam
    
    If lngCdate >= 20050101 Then
        lngEdate = lngCdate
    End If
    
    
    If Skey <> "1" And Lkey <> "1" And Xkey <> "1" And Cname <> "1" And CData <> "1" And lngCdate <= lngEdate Then
        userSkey = Len(Cname)
        For I = 1 To Len(Cname)
            If I < 9 Then
                userSkey = userSkey + Asc(Mid(Cname, I, 1))
            End If
        Next
        userLkey = userSkey
        For I = 1 To Len(Cname)
            userLkey = userLkey + (I * Asc(Mid(Cname, I, 1)))
        Next
        userXkey = userLkey
        For I = 1 To Len(Cname)
            userXkey = userXkey + (I * Asc(Mid(Cname, I, 1)))
            userXkey = userXkey + (I * 5 * Asc(Mid(Cname, I, 1)))
        Next
        If (Val(Skey) = userSkey And Val(Lkey) = userLkey And Val(Xkey) = userXkey) Then
            Check_Shareware = CNaam
        End If
    End If
End Function

Public Sub Debugger(strText As String)
    Dim curDate
    Dim filePTR
    Dim strFilename As String
        
        
    If myDebug = False Then Exit Sub
    
    filePTR = FreeFile
    strFilename = strProgramdir & "\debug.txt"
    Open strFilename For Append As #filePTR
    Print #filePTR, Format(Now, "yyyy-mm-dd hh:nn:ss") & " "; strProgram & ": " & strText
    Close #filePTR
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 Exists(strName As String) As Boolean
    Dim intStatus As Integer
    
    intStatus = -1
    On Error Resume Next
    intStatus = GetAttr(strName)
    If intStatus <> -1 Then
        Exists = True
    Else
        Exists = False
    End If
    
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 GetSecurity(gsIndex As Integer) As Boolean
    Dim gsPos As Long
    Dim gsString As String
    
    GetSecurity = False
    If INI_GetKey("DEFAULT", Format(mySecurity(gsIndex), "00"), strProgramdir & strThemedir & strThemeName & ".ini") = True Then
        gsString = iniValue
        gsPos = InStr(gsString, ",")
        gsPos = InStr(gsPos + 1, gsString, ",")
        gsPos = InStr(gsPos + 1, gsString, ",")
        gsPos = InStr(gsPos + 1, gsString, ",")
        gsPos = InStr(gsPos + 1, gsString, ",")
        gsPos = InStr(gsPos + 1, gsString, ",")
        gsPos = InStr(gsPos + 1, gsString, ",")
        gsPos = InStr(gsPos + 1, gsString, ",")
        gsString = Mid(gsString, gsPos + 1)
        GetSecurity = Mid(gsString, 1, InStr(gsString, ",") - 1)
    ElseIf INI_GetKey("DEFAULT", Format(mySecurity(gsIndex), "00"), strProgramdir & strThemedir & strThemeName & ".skn") = True Then
        gsString = iniValue
        gsPos = InStr(gsString, ",")
        gsPos = InStr(gsPos + 1, gsString, ",")
        gsPos = InStr(gsPos + 1, gsString, ",")
        gsPos = InStr(gsPos + 1, gsString, ",")
        gsPos = InStr(gsPos + 1, gsString, ",")
        gsPos = InStr(gsPos + 1, gsString, ",")
        gsPos = InStr(gsPos + 1, gsString, ",")
        gsPos = InStr(gsPos + 1, gsString, ",")
        gsString = Mid(gsString, gsPos + 1)
        GetSecurity = Mid(gsString, 1, InStr(gsString, ",") - 1)
    End If
End Function

Public Function GetShortName(ByVal sLongFileName As String) As String
    Dim lRetVal As Long, sShortPathName As String, iLen As Integer

    sShortPathName = Space(255)
    iLen = Len(sShortPathName)

    lRetVal = GetShortPathName(sLongFileName, sShortPathName, iLen)
    GetShortName = Left(sShortPathName, lRetVal)
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 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 LoadControls(myForm As Form, _
ByRef mySection As String, _
ByRef myBcount, _
ByRef myLCButtons, _
ByRef myLCActions, _
ByRef myLCSndClick, _
ByRef myLCSndOver, _
ByRef myLCSecurity, _
ByRef myAcount, _
ByRef myAframe, _
ByRef myLCAnimStart, _
ByRef myLCAnimEnd, _
ByRef myLCAnimCurrent, _
ByRef myLCAnim, _
ByRef myLCSleep, _
ByRef mySknfile As String)
            
            
    Dim myCounter As Long
    Dim myPicture As Long
    Dim myTextbox As Long
    Dim myKomma As Long
    Dim myFilename As String
    Dim myMode As String
    Dim myLeft As Long
    Dim myTop As Long
    Dim myWidth As Long
    Dim myHeight As Long
    Dim myTemp As String
    Dim GifEnd
    Dim fptr
    Static buf$, picbuf$
    Dim imgHeader As String
    Dim I, J As Long
    Dim fileHeader As String
    Dim TimeWait As Long
    Dim tmpiniValue As String
    
    myBcount = 0
    myCounter = 0
    myPicture = 0
    myTextbox = 0
    myAcount = 0
    myAframe = 0
    While INI_GetKey(mySection, Format(myCounter + 1, "00"), mySknfile) = True
        tmpiniValue = iniValue
        If (INI_GetKey(mySection, Format(myCounter + 1, "00"), Mid(mySknfile, 1, Len(mySknfile) - 3) & "ini") = True) Then
            tmpiniValue = iniValue
        End If
        iniValue = tmpiniValue
        myKomma = InStr(iniValue, ",") + 1
        myFilename = Mid(iniValue, 1, myKomma - 2)
        myMode = Mid(iniValue, myKomma, InStr(myKomma, iniValue, ",") - myKomma)
        myKomma = InStr(myKomma + 1, iniValue, ",") + 1
        If myMode = "L" Then
            '08=null,T,-350,50,0,-180,0,0,0,255,128,0,courier,10
            myTextbox = myTextbox + 1
            Load myForm.txtBox(myTextbox)
            myLeft = Val(Mid(iniValue, myKomma, InStr(myKomma, iniValue, ",") - myKomma))
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myTop = Val(Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma))
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myWidth = Val(Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma))
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myHeight = Val(Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma))
            If myLeft < 0 Then myLeft = myForm.ScaleWidth + myLeft
            If myTop < 0 Then myTop = myForm.ScaleHeight + myTop
            If myWidth <= 0 Then myWidth = myForm.ScaleWidth + myWidth - myLeft
            If myHeight <= 0 Then myHeight = myForm.ScaleHeight + myHeight - myTop
            myForm.txtBox(myTextbox).Left = myLeft
            myForm.txtBox(myTextbox).Width = myWidth
            myForm.txtBox(myTextbox).Top = myTop
            myForm.txtBox(myTextbox).Height = myHeight
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myLeft = Val(Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma))
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myTop = Val(Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma))
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myWidth = Val(Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma))
            myForm.txtBox(myTextbox).BackColor = RGB(myLeft, myTop, myWidth)
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myLeft = Val(Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma))
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myTop = Val(Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma))
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myWidth = Val(Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma))
            myForm.txtBox(myTextbox).ForeColor = RGB(myLeft, myTop, myWidth)
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myFilename = Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma)
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myLeft = Val(Mid(iniValue, myKomma))
            'myForm.txtBox(myTextbox).MultiLine = True
            myForm.txtBox(myTextbox).FontName = myFilename
            myForm.txtBox(myTextbox).FontSize = myLeft
            myForm.txtBox(myTextbox).Text = ""
            myForm.txtBox(myTextbox).Enabled = True
            myForm.txtBox(myTextbox).Visible = True
        End If
        If myMode = "C" Then
            '08=null,T,-350,50,0,-180,0,0,0,255,128,0,courier,10
            myLeft = Val(Mid(iniValue, myKomma, InStr(myKomma, iniValue, ",") - myKomma))
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myTop = Val(Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma))
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myWidth = Val(Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma))
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myHeight = Val(Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma))
            If myLeft < 0 Then myLeft = myForm.ScaleWidth + myLeft
            If myTop < 0 Then myTop = myForm.ScaleHeight + myTop
            If myWidth <= 0 Then myWidth = myForm.ScaleWidth + myWidth - myLeft
            If myHeight <= 0 Then myHeight = myForm.ScaleHeight + myHeight - myTop
            Select Case LCase(myFilename)
                Case "execute"
                    myForm.cmdExecute.Left = myLeft
                    myForm.cmdExecute.Width = myWidth
                    myForm.cmdExecute.Top = myTop
                    myForm.cmdExecute.Height = myHeight
                Case "quick"
                    myForm.lstAction.Left = myLeft
                    myForm.lstAction.Width = myWidth
                    myForm.lstAction.Top = myTop
                    myForm.lstAction.Height = myHeight
                Case "task"
                    myForm.cmdTasks.Left = myLeft
                    myForm.cmdTasks.Width = myWidth
                    myForm.cmdTasks.Top = myTop
            End Select
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myLeft = Val(Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma))
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myTop = Val(Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma))
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myWidth = Val(Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma))
            Select Case LCase(myFilename)
                Case "execute"
                    myForm.cmdExecute.BackColor = RGB(myLeft, myTop, myWidth)
                Case "quick"
                    myForm.lstAction.BackColor = RGB(myLeft, myTop, myWidth)
                Case "task"
                    myForm.cmdTasks.BackColor = RGB(myLeft, myTop, myWidth)
            End Select
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myLeft = Val(Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma))
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myTop = Val(Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma))
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myWidth = Val(Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma))
            Select Case LCase(myFilename)
                Case "execute"
                    myForm.cmdExecute.ForeColor = RGB(myLeft, myTop, myWidth)
                Case "quick"
                    myForm.lstAction.ForeColor = RGB(myLeft, myTop, myWidth)
                Case "task"
                    myForm.cmdTasks.ForeColor = RGB(myLeft, myTop, myWidth)
            End Select
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            tmpiniValue = Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma)
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myLeft = Val(Mid(iniValue, myKomma))
            'myForm.txtBox(myTextbox).MultiLine = True
            Select Case LCase(myFilename)
                Case "execute"
                    myForm.cmdExecute.FontName = tmpiniValue
                    myForm.cmdExecute.FontSize = myLeft
                    myForm.cmdExecute.Text = ""
                    myForm.cmdExecute.Enabled = True
                    myForm.cmdExecute.Visible = True
                Case "quick"
                    myForm.lstAction.FontName = tmpiniValue
                    myForm.lstAction.FontSize = myLeft
                    'myForm.cmdQuick.Text = ""
                    myForm.lstAction.Enabled = True
                    myForm.lstAction.Visible = True
                Case "task"
                    myForm.cmdTasks.FontName = tmpiniValue
                    myForm.cmdTasks.FontSize = myLeft
                    'myForm.cmdTasks.Text = ""
                    myForm.cmdTasks.Enabled = True
                    myForm.cmdTasks.Visible = True
            End Select
        End If
        If myMode = "P" Then
            myPicture = myPicture + 1
            Load myForm.imgPic(myPicture)
            myForm.imgPic(myPicture).Enabled = False
            myForm.imgPic(myPicture).Stretch = True
            myTemp = Mid(iniValue, myKomma, InStr(myKomma, iniValue, ",") - myKomma)
            If (Right(myTemp, 1) = "%") Then
                myLeft = Val((myForm.ScaleWidth * Val(myTemp)) / 100)
            Else
                myLeft = Val(myTemp)
            End If
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myTemp = Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma)
            If (Right(myTemp, 1) = "%") Then
                myTop = Val((myForm.ScaleHeight * Val(myTemp)) / 100)
            Else
                myTop = Val(myTemp)
            End If
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myTemp = Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma)
            If (Right(myTemp, 1) = "%") Then
                myWidth = Val((myForm.ScaleWidth * Val(myTemp)) / 100)
            Else
                myWidth = Val(myTemp)
            End If
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myTemp = Mid(iniValue, myKomma)
            If (Right(myTemp, 1) = "%") Then
                myHeight = Val((myForm.ScaleHeight * Val(myTemp)) / 100)
            Else
                myHeight = Val(myTemp)
            End If
            If myLeft < 0 Then myLeft = myForm.ScaleWidth + myLeft
            If myTop < 0 Then myTop = myForm.ScaleHeight + myTop
            If myWidth <= 0 Then myWidth = myForm.ScaleWidth + myWidth - myLeft
            If myHeight <= 0 Then myHeight = myForm.ScaleHeight + myHeight - myTop
            myForm.imgPic(myPicture).Left = myLeft
            myForm.imgPic(myPicture).Width = myWidth
            myForm.imgPic(myPicture).Top = myTop
            myForm.imgPic(myPicture).Height = myHeight
            myForm.imgPic(myPicture).Picture = LoadPicture(strProgramdir & strThemedir & myFilename)
            myForm.imgPic(myPicture).Visible = True
        End If
        If myMode = "B" Then
            myBcount = myBcount + 1
            ReDim Preserve myLCButtons(myBcount)
            ReDim Preserve myLCActions(myBcount)
            ReDim Preserve myLCSndClick(myBcount)
            ReDim Preserve myLCSndOver(myBcount)
            ReDim Preserve myLCSecurity(myBcount)
            Load myForm.imgBut(myBcount)
            myForm.imgBut(myBcount).Visible = True
            
            myLeft = Val(Mid(iniValue, myKomma, InStr(myKomma, iniValue, ",") - myKomma))
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myTop = Val(Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma))
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myWidth = Val(Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma))
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myHeight = Val(Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma))
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myLCSndOver(myBcount) = Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma)
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myLCSndClick(myBcount) = Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - myKomma)
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myLCSecurity(myBcount) = myCounter + 1
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myLCActions(myBcount) = Mid(iniValue, myKomma)
            If myLeft < 0 Then myLeft = myForm.ScaleWidth + myLeft
            If myTop < 0 Then myTop = myForm.ScaleHeight + myTop
            If myWidth < 0 Then myWidth = myForm.ScaleWidth + myWidth - myLeft
            If myHeight < 0 Then myHeight = myForm.ScaleHeight + myHeight - myTop
            myForm.imgBut(myBcount).Left = myLeft
            myForm.imgBut(myBcount).Width = myWidth
            myForm.imgBut(myBcount).Top = myTop
            myForm.imgBut(myBcount).Height = myHeight
            myForm.imgBut(myBcount).Picture = LoadPicture(strProgramdir & strThemedir & myFilename)
            myLCButtons(myBcount) = strProgramdir & strThemedir & myFilename
        End If
        
        If myMode = "A" Then
            GifEnd = Chr(0) & "!ù"
            myAcount = myAcount + 1
            ReDim Preserve myLCAnimStart(myAcount)
            ReDim Preserve myLCAnimEnd(myAcount)
            ReDim Preserve myLCAnimCurrent(myAcount)
            
            myLCAnimStart(myAcount) = myAframe + 1
            myLeft = Val(Mid(iniValue, myKomma, InStr(myKomma, iniValue, ",") - 1))
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myTop = Val(Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - 1))
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myWidth = Val(Mid(iniValue, myKomma, InStr(myKomma + 1, iniValue, ",") - 1))
            myKomma = InStr(myKomma + 1, iniValue, ",") + 1
            myHeight = Val(Mid(iniValue, myKomma))
            If myLeft < 0 Then myLeft = myForm.ScaleWidth + myLeft
            If myTop < 0 Then myTop = myForm.ScaleHeight + myTop
            If myWidth < 0 Then myWidth = myForm.ScaleWidth + myWidth - myLeft
            If myHeight < 0 Then myHeight = myForm.ScaleHeight + myHeight - myTop
            
            fptr = FreeFile
            Open strProgramdir & strThemedir & myFilename For Binary Access Read As fptr
                buf = String(LOF(fptr), Chr(0))
                Get #fptr, , buf
            Close fptr
        
            I = 1
        
            J = (InStr(1, buf, GifEnd) + Len(GifEnd)) - 2
            fileHeader = Left(buf, J)
            I = J + 2
        
            Load myForm.tmrAnim(myAcount)
            myForm.tmrAnim(myAcount).Enabled = False
            Do
                J = InStr(I, buf, GifEnd) + Len(GifEnd)
                If J > Len(GifEnd) Then
                    myAframe = myAframe + 1
                    fptr = FreeFile
                    Open "tmp.gif" For Binary As fptr
                    picbuf = String(Len(fileHeader) + J - I, Chr(0))
                    picbuf = fileHeader & Mid(buf, I - 1, J - I)
                    Put #fptr, 1, picbuf
                    imgHeader = Left(Mid(buf, I - 1, J - I), 16)
                    Close fptr
                
                    TimeWait = ((Asc(Mid(imgHeader, 4, 1))) + (Asc(Mid(imgHeader, 5, 1)) * CLng(256))) * CLng(10)
                    Load myForm.imgGif(myAframe)
                    myForm.imgGif(myAframe).ZOrder 0
                    myForm.imgGif(myAframe).Stretch = True
                    myForm.imgGif(myAframe).Left = myLeft
                    myForm.imgGif(myAframe).Top = myTop
                    myForm.imgGif(myAframe).Width = myWidth
                    myForm.imgGif(myAframe).Height = myHeight
                    myForm.imgGif(myAframe).Tag = TimeWait
                    myForm.imgGif(myAframe).Picture = LoadPicture("tmp.gif")
                    myForm.imgGif(myAframe).Enabled = False
                    If (myAframe = myLCAnimStart(myAcount)) Then myForm.imgGif(myAframe).Visible = True
                    Kill ("tmp.gif")
                    I = J
                End If
                DoEvents
            Loop Until J = Len(GifEnd)
        
            If I < Len(buf) Then
                myAframe = myAframe + 1
                fptr = FreeFile
                Open "tmp.gif" For Binary As fptr
                    picbuf = String(Len(fileHeader) + Len(buf) - I, Chr(0))
                    picbuf = fileHeader & Mid(buf, I - 1, Len(buf) - I)
                    Put #fptr, 1, picbuf
                    imgHeader = Left(Mid(buf, I - 1, Len(buf) - I), 16)
                Close fptr
    
                TimeWait = ((Asc(Mid(imgHeader, 4, 1))) + (Asc(Mid(imgHeader, 5, 1)) * CLng(256))) * CLng(10)
                Load myForm.imgGif(myAframe)
                myForm.imgGif(myAframe).ZOrder 0
                myForm.imgGif(myAframe).Stretch = True
                myForm.imgGif(myAframe).Left = myLeft
                myForm.imgGif(myAframe).Top = myTop
                myForm.imgGif(myAframe).Width = myWidth
                myForm.imgGif(myAframe).Height = myHeight
                myForm.imgGif(myAframe).Tag = TimeWait
                myForm.imgGif(myAframe).Picture = LoadPicture("tmp.gif")
                myForm.imgGif(myAframe).Enabled = False
                If (myAframe = myLCAnimStart(myAcount)) Then myForm.imgGif(myAframe).Visible = True
                Kill ("tmp.gif")
            End If
        
            myLCAnimEnd(myAcount) = myAframe
            myLCAnimCurrent(myAcount) = myLCAnimStart(myAcount)
        
            On Error GoTo badTime
            myForm.tmrAnim(myAcount).Interval = CInt(myForm.imgGif(myLCAnimStart(myAcount)).Tag)
badTime:
            myForm.tmrAnim(myAcount).Enabled = True
        End If
        
        myCounter = myCounter + 1
        If myLCAnim = True Then
            Sleep myLCSleep
        End If
        DoEvents
    Wend
End Sub

Public Function mkSkin(ByVal Form As Form, ByVal cTransparent As Long, Optional Image As String) As Boolean
    Dim iImage As BITMAPHEADER
    Dim Ret As Long
    Dim xdcImage, ydcImage As Byte
    Dim tImage As Boolean
    Dim bImage, bpImage, cImage, dtImage, etImage, hImage, hRgn, hRgnt, sImage, xImage, xMax, yImage, yMax As Long
    Dim lngRow As Long
    Dim lngCol As Long
    Dim lngStart As Long
    
    Dim OSInfo As OSVERSIONINFO
    Dim IsWindowsNTa As Boolean

    With OSInfo
        .dwOSVersionInfoSize = Len(OSInfo)
        .szCSDVersion = Space$(128)
        GetVersionEx OSInfo
        IsWindowsNTa = (.dwPlatformId = VER_PLATFORM_WIN32_NT)
    End With
    If IsWindowsNTa = True Then
        Form.Picture = LoadPicture(Image)
        hImage = Form.Picture
        GetObject Form.Picture, Len(iImage), iImage
        xMax = iImage.bmWidth
        yMax = iImage.bmHeight
        Form.Width = xMax * Screen.TwipsPerPixelX
        Form.Height = yMax * Screen.TwipsPerPixelY
        
        
        'Set the window style to 'Layered'
        Ret = GetWindowLong(Form.hWnd, GWL_EXSTYLE)
        Ret = Ret Or WS_EX_LAYERED
        SetWindowLong Form.hWnd, GWL_EXSTYLE, Ret
        'Set the opacity of the layered window to 128
        SetLayeredWindowAttributes Form.hWnd, cTransparent, 0, LWA_COLORKEY
        Form.Refresh
    Else
        Form.Picture = LoadPicture(Image)
        hImage = Form.Picture
        GetObject Form.Picture, Len(iImage), iImage
        xMax = iImage.bmWidth
        yMax = iImage.bmHeight
        hRgn = CreateRectRgn(0, 0, 0, 0)
        bpImage = 3
        sImage = xMax * yMax * bpImage
        Form.Width = xMax * Screen.TwipsPerPixelX
        Form.Height = yMax * Screen.TwipsPerPixelY
        ReDim pbImage(0 To sImage) As Byte
        ReDim pimage(0 To xMax, 0 To yMax) As Long
        GetBitmapBits hImage, sImage, pbImage(0)
        For bImage = 0 To sImage - 3 Step bpImage
            yImage = Int((bImage) / (xMax * bpImage))
            xImage = ((bImage) / bpImage) - ((yImage) * xMax)
            pimage(xImage, yImage) = RGB(pbImage(bImage), pbImage(bImage + 1), pbImage(bImage + 2))
        Next bImage
            
        For lngRow& = 0 To yMax - 1
            lngCol& = 0
            Do While lngCol& < xMax
                Do While lngCol& < xMax And pimage(lngCol, lngRow) = cTransparent
                    lngCol& = lngCol& + 1
                Loop
                If lngCol& < xMax Then
                    lngStart& = lngCol&
                    Do While lngCol& < xMax And pimage(lngCol, lngRow) <> cTransparent
                        lngCol& = lngCol& + 1
                    Loop
                    If lngCol& > xMax Then lngCol& = xMax
                    hRgnt = CreateRectRgn(lngStart&, lngRow&, lngCol&, lngRow& + 1)
                    CombineRgn hRgn, hRgn, hRgnt, 2
                    DeleteObject (hRgnt)
                End If
            Loop
        Next
            
        mkSkin = SetWindowRgn(Form.hWnd, hRgn, 1)
        DeleteObject hRgn
        Form.Refresh
    End If
End Function

Public Sub Mouse_Get(myForm As Form)
    Dim mouseco As POINTAPI
    
    GetCursorPos mouseco
    mouseX = mouseco.X - (myForm.Left \ Screen.TwipsPerPixelX)
    mouseY = mouseco.Y - (myForm.Top \ Screen.TwipsPerPixelY)
    mouseH = WindowFromPoint(mouseco.X, mouseco.Y)
End Sub

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

Public Sub PlaySound(mySound As String, myWait As Boolean)
    Dim Variable
    Dim strSound As String
    Dim booSound As Boolean
    Dim booMultiple As Boolean
    
    booSound = True
    On Error Resume Next
    If INI_GetKey("DEFAULT", "Sound", strProgramdir & strThemedir & "terminal.skn") = True Then
        booSound = iniValue
    End If
    If booSound = False Then Exit Sub
    
    booMultiple = False
    If INI_GetKey("DEFAULT", "Multiple", strProgramdir & strThemedir & "terminal.skn") = True Then
        booMultiple = iniValue
    End If
    
    Variable = 0
    If InStr(mySound, ":") > 0 Then
        strSound = GetShortName(mySound)
    Else
        strSound = GetShortName(strProgramdir & strThemedir & mySound & ".wav")
    End If
    Variable = FileLen(strSound)
    If (Variable > 0) Then
        If myWait = True Then
            If booMultiple = True Then
                Variable = mciExecute("play " & strSound & " wait")
            Else
                Variable = PlaySoundNow(strSound, 1, 0)
            End If
        Else
            If booMultiple = True Then
                Variable = mciExecute("play " & strSound)
            Else
                Variable = PlaySoundNow(strSound, 1, &H1)
            End If
        End If
    End If
End Sub

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 ReadExecuteList(myForm As Form)
    Dim strPos As String
    Dim strValue As String
    Dim myRed As Long
    
    myForm.cmdExecute.Clear
    strVolgorde = RegistryGet("Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU", "MRUList", HKEY_CURRENT_USER)
    If (strVolgorde <> "") Then
        For myRed = 1 To Len(strVolgorde)
            strPos = Mid(strVolgorde, myRed, 1)
            strValue = RegistryGet("Software\microsoft\Windows\CurrentVersion\Explorer\RunMRU", strPos, HKEY_CURRENT_USER)
            If (strValue <> "") Then
                myForm.cmdExecute.AddItem Mid(strValue, 1, Len(strValue) - 2)
                myForm.cmdExecute.ListIndex = 0
            End If
        Next
    Else
        strVolgorde = "a"
    End If
    myForm.cmdExecute.ListIndex = -1
End Function

Public Function ReadQuickList(myForm As Form)
    Dim strQuicklaunch As String
    Dim lngLoop As Long
    Dim lngTopbuttons As Long
    
    frmMain.List1.Clear
    strQuicklaunch = RegistryGet("Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "AppData", HKEY_CURRENT_USER)
    If (strQuicklaunch <> "") Then
        frmMain.File1.Path = strQuicklaunch & "\Microsoft\Internet Explorer\Quick Launch"
        For lngLoop = 0 To frmMain.File1.ListCount - 1
            frmMain.List1.AddItem strQuicklaunch & "\Microsoft\Internet Explorer\Quick Launch\" & frmMain.File1.List(lngLoop) & "|" & Left(frmMain.File1.List(lngLoop), Len(frmMain.File1.List(lngLoop)) - 4)
            frmMain.List1.ItemData(frmMain.List1.NewIndex) = lngLoop
        Next
    End If
    myForm.lstAction.Clear
    For lngLoop = 0 To frmMain.List1.ListCount - 1
        strQuicklaunch = frmMain.List1.List(lngLoop)
        myForm.lstAction.AddItem Mid(strQuicklaunch, InStr(strQuicklaunch, "|") + 1)
        myForm.lstAction.ItemData(myForm.lstAction.NewIndex) = lngLoop
    Next
End Function

Public Function ReadStartList(myForm As Form)
    Dim strDir As String
    Dim lngLoop As Long
    Dim strLast As String
    
    strStartSubdir = ""
    'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
    strStartRootA = RegistryGet("Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "Start Menu", HKEY_CURRENT_USER)
    frmMain.Dir1.Path = strStartRootA
    frmMain.File1.Path = strStartRootA
    frmMain.List1.Clear
    For lngLoop = 0 To frmMain.Dir1.ListCount - 1
        frmMain.List1.AddItem "[" & Mid(frmMain.Dir1.List(lngLoop), Len(strStartRootA) + 2) & "]"
    Next
    For lngLoop = 0 To frmMain.File1.ListCount - 1
        frmMain.List1.AddItem frmMain.File1.List(lngLoop)
    Next
    
    strStartRootB = RegistryGet("Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "Common Start Menu", HKEY_LOCAL_MACHINE)
    frmMain.Dir1.Path = strStartRootB
    frmMain.File1.Path = strStartRootB
    For lngLoop = 0 To frmMain.Dir1.ListCount - 1
        frmMain.List1.AddItem "[" & Mid(frmMain.Dir1.List(lngLoop), Len(strStartRootB) + 2) & "]"
    Next
    For lngLoop = 0 To frmMain.File1.ListCount - 1
        frmMain.List1.AddItem frmMain.File1.List(lngLoop)
    Next
    
    
    myForm.lstAction.Clear
    strLast = ""
    For lngLoop = 0 To frmMain.List1.ListCount - 1
        strDir = frmMain.List1.List(lngLoop)
        If strDir <> strLast Then
            myForm.lstAction.AddItem strDir
            myForm.lstAction.ItemData(myForm.lstAction.NewIndex) = lngLoop
        End If
        strLast = strDir
    Next
    
    ReadStartListNow myForm
End Function

Public Function ReadStartListNow(myForm As Form)
    Dim strDir As String
    Dim lngLoop As Long
    Dim strLast As String
    Dim strDirA As String
    Dim strDirB As String
    
    If strStartSubdir = "" Then
        strDirA = strStartRootA
        strDirB = strStartRootB
    Else
        strDirA = strStartRootA & "\" & strStartSubdir
        strDirB = strStartRootB & "\" & strStartSubdir
    End If
    
    frmMain.lstSorted.Clear
    If strStartSubdir <> "" Then
        frmMain.lstSorted.AddItem " [..]"
    End If
    
    If Exists(strDirA) = True Then
        frmMain.Dir1.Path = strDirA
        frmMain.File1.Path = strDirA
        For lngLoop = 0 To frmMain.Dir1.ListCount - 1
            frmMain.lstSorted.AddItem " [" & Mid(frmMain.Dir1.List(lngLoop), Len(strDirA) + 2) & "]"
        Next
        For lngLoop = 0 To frmMain.File1.ListCount - 1
            frmMain.lstSorted.AddItem frmMain.File1.List(lngLoop)
        Next
    End If
    
    If Exists(strDirB) = True Then
        frmMain.Dir1.Path = strDirB
        frmMain.File1.Path = strDirB
        For lngLoop = 0 To frmMain.Dir1.ListCount - 1
            frmMain.lstSorted.AddItem " [" & Mid(frmMain.Dir1.List(lngLoop), Len(strDirB) + 2) & "]"
        Next
        For lngLoop = 0 To frmMain.File1.ListCount - 1
            frmMain.lstSorted.AddItem frmMain.File1.List(lngLoop)
        Next
    End If
        
    myForm.lstAction.Clear
    strLast = ""
    For lngLoop = 0 To frmMain.lstSorted.ListCount - 1
        strDir = Trim(frmMain.lstSorted.List(lngLoop))
        If strDir <> strLast Then
            If Left(strDir, 1) = "[" And Right(strDir, 1) = "]" Then
                myForm.lstAction.AddItem strDir
            Else
                myForm.lstAction.AddItem Left(strDir, Len(strDir) - 4)
            End If
            myForm.lstAction.ItemData(myForm.lstAction.NewIndex) = lngLoop
        End If
        strLast = strDir
    Next
    
End Function

Public Function ReadTaskList(myForm As Form)
    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
    
    frmMain.lstTask.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)
                        frmMain.lstTask.AddItem (CStr(currWnd) & "|" & listItem$)
                    End If
                End If
            End If
        End If
        currWnd = GetWindow(currWnd, GW_HWNDNEXT)
    Wend
    myForm.lstAction.Clear
    For IsTask = 0 To frmMain.lstTask.ListCount - 1
        myForm.lstAction.AddItem Mid(frmMain.lstTask.List(IsTask), InStr(frmMain.lstTask.List(IsTask), "|") + 1)
        myForm.lstAction.ItemData(myForm.lstAction.NewIndex) = IsTask
    Next
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)
    Dim strCommand As String
    Dim strParam As String
    Dim lngChr As Long
    
    If Left(sfPath, 1) = Chr(34) Then
        lngChr = InStr(2, sfPath, Chr(34))
        strCommand = Mid(sfPath, 1, lngChr)
        strParam = Mid(sfPath, lngChr)
    ElseIf InStr(sfPath, " ") Then
        lngChr = InStr(1, sfPath, " ")
        strCommand = Mid(sfPath, 1, lngChr - 1)
        strParam = Mid(sfPath, lngChr + 1)
    Else
        strCommand = sfPath
        strParam = ""
    End If
    On Error Resume Next
    'ShellFile = ShellExecute(frmMain.hwnd, "open", sfPath, "", "", 1)
    ShellFile = ShellExecute(frmMain.hWnd, "open", strCommand, strParam, "", 1)
End Function

Public Function ShellReplacement() As Boolean
    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 Sub Startup_Form(myForm As Form)
    Dim lngCWnd As Long
    Dim booRunning As Boolean
    Dim myKomma As Long
    Dim myRed As Long
    Dim myGreen As Long
    Dim myBlue As Long
    Dim mySound As String
    
    myForm.cmdFake.Left = -100
    myForm.cmdFake.Visible = False

    If (App.PrevInstance) Then
        myForm.Caption = "Piet van Stralen"
        lngCWnd = Activate_Application
        If lngCWnd <> -1 Then
            SetWindowPos lngCWnd, conHwndTopmost, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
            SetWindowPos lngCWnd, conHwndTopNot, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
        End If
        Debugger "Program already running, exiting"
        End
    Else
        myForm.Caption = strApplication
    End If
    
    SaveSetting "LCARS Terminal", "EXIT", strApplication, "0"
    SaveSetting "LCARS Terminal", "Voice", strProgram, ""
    strProgramdir = GetSetting("LCARS Terminal", "Default", "ProgramDir", "")
    strThemedir = GetSetting("LCARS Terminal", "Default", "ThemeDir", "")
    myControls = myForm.Controls.Count
    Debugger "Starting Program, Reading Startup_Form"

    strThemeName = strProgram & CStr(Screen.Width / Screen.TwipsPerPixelX)
    If INI_GetKey("DEFAULT", "BackGround", strProgramdir & strThemedir & strThemeName & ".skn") = False Then
        strThemeName = strProgram
    End If

    
    If INI_GetKey("DEFAULT", "size", strProgramdir & strThemedir & strThemeName & ".skn") = True Then
        myKomma = InStr(iniValue, ",") + 1
        myDesktopLeft = Val(Mid(iniValue, 1, myKomma - 2))
        If myDesktopLeft < 0 Then myDesktopLeft = (Screen.Width / Screen.TwipsPerPixelX) + myDesktopLeft
        myForm.Left = myDesktopLeft * Screen.TwipsPerPixelX
        myDesktopTop = Val(Mid(iniValue, myKomma, InStr(myKomma, iniValue, ",") - 1))
        If myDesktopTop < 0 Then myDesktopTop = (Screen.Height / Screen.TwipsPerPixelY) + myDesktopTop
        myForm.Top = myDesktopTop * Screen.TwipsPerPixelY
        myKomma = InStr(myKomma + 1, iniValue, ",") + 1
        myRed = Val(Mid(iniValue, myKomma, InStr(myKomma, iniValue, ",") - 1)) * Screen.TwipsPerPixelX
        If myRed = 0 Then myRed = Screen.Width
        If myRed < 0 Then myRed = Screen.Width + myRed - myForm.Left
        myForm.Width = myRed
        myKomma = InStr(myKomma + 1, iniValue, ",") + 1
        myRed = Val(Mid(iniValue, myKomma)) * Screen.TwipsPerPixelY
        If myRed = 0 Then myRed = Screen.Height
        If myRed < 0 Then myRed = Screen.Height + myRed - myForm.Top
        myForm.Height = myRed
    End If
    
    myPassword = GetSetting("LCARS Terminal", "DEFAULT", "Password", "")

    If INI_GetKey("DEFAULT", "Animated", strProgramdir & strThemedir & "terminal.skn") = True Then
        myAnim = iniValue
    End If
    If INI_GetKey("DEFAULT", "Debug", strProgramdir & strThemedir & "terminal.skn") = True Then
        myDebug = iniValue
    End If
    If INI_GetKey("DEFAULT", "AnimDelay", strProgramdir & strThemedir & "terminal.skn") = True Then
        mySleep = iniValue
    End If
    If INI_GetKey("ABOUT", "Text-Register", strProgramdir & strThemedir & "terminal.skn") = True Then
        RegisterText = iniValue
    Else
        RegisterText = "This program is Shareware. If you like this program please register it."
    End If


    If INI_GetKey("DEFAULT", "BackGround", strProgramdir & strThemedir & strThemeName & ".skn") = True Then
        myKomma = InStr(iniValue, ",") + 1
        myRed = Val(Mid(iniValue, 1, myKomma - 2))
        myGreen = Val(Mid(iniValue, myKomma, InStr(myKomma, iniValue, ",") - 1))
        myKomma = InStr(myKomma + 1, iniValue, ",") + 1
        myBlue = Val(Mid(iniValue, myKomma))
        myForm.BackColor = RGB(myRed, myGreen, myBlue)
    End If
    If INI_GetKey("DEFAULT", "StartupSound", strProgramdir & strThemedir & strThemeName & ".skn") = True Then
        mySound = iniValue
        PlaySound mySound, False
    End If
    Debugger "Reading config files"
    myForm.Show
    DoEvents
    Debugger "Reading LoadControls"
    LoadControls myForm, "DEFAULT", myButCount, myButtons, myActions, mySndClick, mySndOver, mySecurity, myAnimCount, myAnimFrame, myAnimStart, myAnimEnd, myAnimCurrent, myAnim, mySleep, strProgramdir & strThemedir & strThemeName & ".skn"
    'systemtray=300,10,-100,15,50,50,50
    If INI_GetKey("DEFAULT", "systemtray", strProgramdir & strThemedir & strThemeName & ".skn") = True Then
        myKomma = InStr(iniValue, ",") + 1
        myRed = Val(Mid(iniValue, 1, myKomma - 2))
        If myRed < 0 Then myRed = myForm.ScaleWidth + myRed
        myForm.SysTray1.Left = myRed
        myRed = Val(Mid(iniValue, myKomma, InStr(myKomma, iniValue, ",") - 1))
        If myRed < 0 Then myRed = myForm.ScaleHeight + myRed
        myForm.SysTray1.Top = myRed
        myKomma = InStr(myKomma + 1, iniValue, ",") + 1
        myRed = Val(Mid(iniValue, myKomma, InStr(myKomma, iniValue, ",") - 1))
        If myRed = 0 Then myRed = myForm.ScaleWidth
        If myRed < 0 Then myRed = myForm.ScaleWidth + myRed - myForm.SysTray1.Left
        myForm.SysTray1.Width = myRed
        myKomma = InStr(myKomma + 1, iniValue, ",") + 1
        myRed = Val(Mid(iniValue, myKomma))
        If myRed = 0 Then myRed = myForm.ScaleHeight
        If myRed < 0 Then myRed = myForm.ScaleHeight + myRed - myForm.SysTray1.Top
        myForm.SysTray1.Height = myRed
        myKomma = InStr(myKomma + 1, iniValue, ",") + 1
        myRed = Val(Mid(iniValue, myKomma))
        myKomma = InStr(myKomma + 1, iniValue, ",") + 1
        myGreen = Val(Mid(iniValue, myKomma))
        myKomma = InStr(myKomma + 1, iniValue, ",") + 1
        myBlue = Val(Mid(iniValue, myKomma))
        myForm.SysTray1.BackColor = RGB(myRed, myGreen, myBlue)
        myForm.SysTray1.Visible = True
    End If

    'datetray=-150,10,-30,20,70,70,70,255,128,0,Courier,10,yyyy.dd hh:ii:ss,dddd d mmmm yyyy
    If INI_GetKey("DEFAULT", "datetray", strProgramdir & strThemedir & strThemeName & ".skn") = True Then
        myKomma = InStr(iniValue, ",") + 1
        myRed = Val(Mid(iniValue, 1, myKomma - 2))
        If myRed < 0 Then myRed = myForm.ScaleWidth + myRed
        myForm.lblTime.Left = myRed
        myRed = Val(Mid(iniValue, myKomma, InStr(myKomma, iniValue, ",") - myKomma))
        If myRed < 0 Then myRed = myForm.ScaleHeight + myRed
        myForm.lblTime.Top = myRed
        myKomma = InStr(myKomma + 1, iniValue, ",") + 1
        myRed = Val(Mid(iniValue, myKomma, InStr(myKomma, iniValue, ",") - myKomma))
        If myRed = 0 Then myRed = myForm.ScaleWidth
        If myRed < 0 Then myRed = myForm.ScaleWidth + myRed - myForm.SysTray1.Left
        myForm.lblTime.Width = myRed
        myKomma = InStr(myKomma + 1, iniValue, ",") + 1
        myRed = Val(Mid(iniValue, myKomma, InStr(myKomma, iniValue, ",") - myKomma))
        If myRed = 0 Then myRed = myForm.ScaleHeight
        If myRed < 0 Then myRed = myForm.ScaleHeight + myRed - myForm.SysTray1.Top
        myForm.lblTime.Height = myRed
        myKomma = InStr(myKomma + 1, iniValue, ",") + 1
        myRed = Val(Mid(iniValue, myKomma, InStr(myKomma, iniValue, ",") - myKomma))
        myKomma = InStr(myKomma + 1, iniValue, ",") + 1
        myGreen = Val(Mid(iniValue, myKomma, InStr(myKomma, iniValue, ",") - myKomma))
        myKomma = InStr(myKomma + 1, iniValue, ",") + 1
        myBlue = Val(Mid(iniValue, myKomma, InStr(myKomma, iniValue, ",") - myKomma))
        myForm.lblTime.BackColor = RGB(myRed, myGreen, myBlue)
        myKomma = InStr(myKomma + 1, iniValue, ",") + 1
        myRed = Val(Mid(iniValue, myKomma, InStr(myKomma, iniValue, ",") - myKomma))
        myKomma = InStr(myKomma + 1, iniValue, ",") + 1
        myGreen = Val(Mid(iniValue, myKomma, InStr(myKomma, iniValue, ",") - myKomma))
        myKomma = InStr(myKomma + 1, iniValue, ",") + 1
        myBlue = Val(Mid(iniValue, myKomma, InStr(myKomma, iniValue, ",") - myKomma))
        myForm.lblTime.ForeColor = RGB(myRed, myGreen, myBlue)
        myKomma = InStr(myKomma + 1, iniValue, ",") + 1
        myForm.lblTime.FontName = Mid(iniValue, myKomma, InStr(myKomma, iniValue, ",") - myKomma)
        myKomma = InStr(myKomma + 1, iniValue, ",") + 1
        myBlue = Mid(iniValue, myKomma)
        myForm.lblTime.FontSize = myBlue
        
        myForm.lblTime.Caption = ""
        myForm.lblTime.Visible = True
    End If


End Sub

Public Sub Stop_Form(myForm As Form)
    Dim myCounter As Long
    On Error Resume Next
   
    If INI_GetKey("DEFAULT", "Animated", strProgramdir & strThemedir & "terminal.skn") = True Then
        myAnim = iniValue
    End If
    If INI_GetKey("DEFAULT", "AnimDelay", strProgramdir & strThemedir & "terminal.skn") = True Then
        mySleep = iniValue
    End If
   
    For myCounter = myForm.Controls.Count - 1 To myControls Step -1
        If myAnim = True And myForm.Controls(myCounter).Visible = True Then
            Sleep mySleep
        End If
        Unload myForm.Controls(myCounter)
        DoEvents
    Next

End Sub

Public Sub SystemTray_Start()
    Dim hKey As Long
    Dim Values As ValKey
    Dim lCount As Long
    Dim strDir As String
    Dim I As Long
    Dim strApp As String
    Dim strCmd As String
    
    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
    
    strDir = RegistryGet("Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "Startup", HKEY_CURRENT_USER)
    frmMain.File1.Path = strDir
    For I = 0 To frmMain.File1.ListCount - 1
        frmMain.lstStartup.AddItem strDir & "\" & frmMain.File1.List(I)
    Next I
    
    strDir = RegistryGet("Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "Common Startup", HKEY_LOCAL_MACHINE)
    frmMain.File1.Path = strDir
    For I = 0 To frmMain.File1.ListCount - 1
        frmMain.lstStartup.AddItem strDir & "\" & frmMain.File1.List(I)
    Next I
    
    For I = 0 To frmMain.lstStartup.ListCount - 1
        strDir = frmMain.lstStartup.List(I)
        'Debug.Print strDir
            
        If Left(strDir, 1) = Chr(34) Then
            strDir = Mid(strDir, 2)
            strApp = Mid(strDir, 1, InStr(strDir, Chr(34)) - 1)
            strCmd = Mid(strDir, InStr(strDir, Chr(34)) + 1)
        Else
            strApp = strDir
            strCmd = ""
        End If
        strDir = GetShortName(strApp)
        If strCmd <> "" Then
            strDir = strDir + strCmd
        End If
        Shell strDir, vbNormalFocus
        'Debug.Print strDir
    Next
End Sub

Public Sub BootUpSysTray(booMode As Boolean)
    Dim hWnd As Long, rctemp As RECT
    
    If booMode = True Then
        HideTaskBarClock
        hWnd = FindWindow("Shell_TrayWnd", vbNullString)
        Call SetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_HIDEWINDOW)
        hWnd = FindWindowEx(hWnd, 0, "TrayNotifyWnd", vbNullString)
        Call GetClientRect(hWnd, SysSize)
        Debug.Print ""
        Debug.Print SysSize.Left
        Debug.Print SysSize.Top
        Debug.Print SysSize.Right
        Debug.Print SysSize.Bottom
        SysBox = hWnd
        parent = GetParent(SysBox)
        SetParent SysBox, frmMain.SysTray1.hWnd
        'SetWindowPos SysBox, 0, 0, 0, 150, 100, 0

        SetWindowPos SysBox, 0, 0, 0, frmMain.SysTray1.Width, frmMain.SysTray1.Height, 0
        'SetWindowPos SysBox, 0, 0, 0, 0, 0, 0
    'Call SendMessage(SysBox, _
                           TVM_SETBKCOLOR, _
                           0, _
                           ByVal RGB(255, 0, 0))  'Change the background
                                                  'color to red.
    
    Else
        hWnd = FindWindow("Shell_TrayWnd", vbNullString)
        Call SetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_SHOWWINDOW)
        SetParent SysBox, parent
        ShowTaskBarClock
        'SetWindowPos SysBox, 0, (Screen.Width / Screen.TwipsPerPixelX) - (SysSize.Right - SysSize.Left), 0, 200, 32, 0
        SetWindowPos SysBox, 0, (Screen.Width / Screen.TwipsPerPixelX) - (SysSize.Right - SysSize.Left), 0, (SysSize.Right - SysSize.Left), (SysSize.Bottom - SysSize.Top), 0
        'SetWindowPos SysBox, 0, 0, 0, 0, 0, SWP_REFRESH
        Call GetClientRect(hWnd, SysSize)
    End If
End Sub

Sub HideTaskBarClock()
    Dim FindClass As Long, FindParent As Long, Handle As Long
    FindClass& = FindWindow("Shell_TrayWnd", vbNullString)
    FindParent& = FindWindowEx(FindClass&, 0, "TrayNotifyWnd", vbNullString)
    Handle& = FindWindowEx(FindParent&, 0, "TrayClockWClass", vbNullString)
    ShowWindow Handle&, SW_HIDE
End Sub

Sub ShowTaskBarClock()
    Dim FindClass As Long, FindParent As Long, Handle As Long
    FindClass& = FindWindow("Shell_TrayWnd", vbNullString)
    FindParent& = FindWindowEx(FindClass&, 0, "TrayNotifyWnd", vbNullString)
    Handle& = FindWindowEx(FindParent&, 0, "TrayClockWClass", vbNullString)
    ShowWindow Handle&, SW_SHOW
End Sub


