File "Startup.inc"

Path: /WeekCal/Startup.inc
File size: 2.5 KB
MIME-type:
Charset: utf-8

'-------------------------------------------------------------------------------------------------
' Routines to manage starting an executable at Windows startup
'-------------------------------------------------------------------------------------------------
%CSIDL_STARTUP        = &H0007 ' <user name>\Start Menu\Programs\Startup
'-------------------------------------------------------------------------------------------------
DECLARE FUNCTION SHGetFolderPath LIB "Shell32.dll" _
    ALIAS "SHGetFolderPathA" (BYVAL hwnd AS DWORD, BYVAL csidl AS LONG, _
    BYVAL hToken AS DWORD, BYVAL dwFlags AS DWORD, pszPath AS ASCIIZ) AS LONG
'-------------------------------------------------------------------------------------------------
FUNCTION Exist(BYVAL fileOrFolder AS STRING) AS LONG
    LOCAL Dummy&
    Dummy& = GETATTR(fileOrFolder)
    FUNCTION = (ERRCLEAR = 0)
END FUNCTION
'-------------------------------------------------------------------------------------------------
FUNCTION StartupFolder AS STRING
    LOCAL szBaseFolder AS ASCIIZ * %MAX_PATH
    ShGetFolderPath (BYVAL 0, %CSIDL_STARTUP, BYVAL 0, BYVAL 0, szBaseFolder)
    FUNCTION = TRIM$(szBaseFolder) + "\"
END FUNCTION
'-------------------------------------------------------------------------------------------------
SUB DeleteStartupShortcut
    KILL StartupFolder & EXE.NAME$ & ".lnk"
END SUB
'-------------------------------------------------------------------------------------------------
FUNCTION ExistStartupShortcut AS LONG
    FUNCTION = IIF(EXIST(StartupFolder & EXE.NAME$ & ".lnk"), 8, 0)
END FUNCTION
'-------------------------------------------------------------------------------------------------
SUB MakeStartupShortcut
    DeleteStartupShortcut
    CreateShortcut _
      StartupFolder & EXE.NAME$ & ".lnk", _ ' 1. the link file to be created
      EXE.FULL$,                          _ ' 2. the file/document where the shortcut should point to
      "",                                 _ ' 3. command-line parameters
      EXE.PATH$,                          _ ' 4. the folder where the executable file should start in
      %SW_SHOW,                           _ ' 5. %SW_SHOW, %SW_HIDE etc.
      EXE.FULL$,                          _ ' 6. icon file or executable file containing an icon
      0,                                  _ ' 7. icon index in the aforementioned file
      "mougino@free.fr"                     ' 8. any comment (stored in the shortcut)
END SUB
'-------------------------------------------------------------------------------------------------