Basic Univers
Procedure CreateLink(PATH$, LINK$, Argument$, DESCRIPTION$, WorkingDirectory$, ShowCommand.l, HotKey.l, IconFile$, IconIndexInFile.l)
  
  ; IShellLInk CONSTANTS for CallCOM
  #ShellLink_QueryInterface = 0
  #ShellLink_AddRef = 4
  #ShellLink_Release = 8
  #ShellLink_GetPath = 12
  #ShellLink_GetIDList = 16
  #ShellLink_SetIDList = 20
  #ShellLink_GetDescription = 24
  #ShellLink_SetDescription = 28
  #ShellLink_GetWorkingDirectory = 32
  #ShellLink_SetWorkingDirectory = 36
  #ShellLink_GetArguments = 40
  #ShellLink_SetArguments = 44
  #ShellLink_GetHotkey = 48
  #ShellLink_SetHotkey = 52
  #ShellLink_GetShowCmd = 56
  #ShellLink_SetShowCmd = 60
  #ShellLink_GetIconLocation = 64
  #ShellLink_SetIconLocation = 68
  #ShellLink_SetRelativePath = 72
  #ShellLink_Resolve = 76
  #ShellLink_SetPath = 80
  
  ; Interface IPersistFile : IPersist
  #PersistFile_Release = 8
  #PersistFile_IsDirty = 16
  #PersistFile_Load = 20
  #PersistFile_Save = 24
  #PersistFile_SaveCompleted = 28
  #PersistFile_GetCurFile = 32
  
  result = 0
  CoInitialize_(0)
  If CoCreateInstance_(?CLSID_ShellLink, 0, 1, ?IID_IShellLink, @psl) = 0
    
    Set_ShellLink_preferences :
    
    ; The file TO which is linked ( = target for the Link )
    CallCOM(#ShellLink_SetPath, psl, PATH$)
    
    ; Arguments for the Target
    CallCOM(#ShellLink_SetArguments, psl, Argument$)
    
    ; Working Directory
    CallCOM(#ShellLink_SetWorkingDirectory, psl, WorkingDirectory$)
    
    ; Description ( also used as Tooltip for the Link )
    CallCOM(#ShellLink_SetDescription, psl, DESCRIPTION$)
    
    ; Show command:
    ; SW_SHOWNORMAL = Default
    ; SW_SHOWMAXIMIZED = aehmm... Maximized
    ; SW_SHOWMINIMIZED = play Unreal Tournament
    CallCOM(#ShellLink_SetShowCmd, psl, ShowCommand)
    
    ; Hotkey:
    ; The virtual key code is in the low-order byte,
    ; and the modifier flags are in the high-order byte.
    ; The modifier flags can be a combination of the following values:
    ; HOTKEYF_ALT = ALT key
    ; HOTKEYF_CONTROL = CTRL key
    ; HOTKEYF_EXT = Extended key
    ; HOTKEYF_SHIFT = SHIFT key
    CallCOM(#ShellLink_SetHotkey, psl, HotKey)
    
    ; Set Icon for the Link:
    ; There can be more than 1 icons in an icon resource file,
    ; so you have to specify the index.
    CallCOM(#ShellLink_SetIconLocation, psl, IconFile$, IconIndexInFile)
    
    ShellLink_SAVE :
    ; Query IShellLink For the IPersistFile interface For saving the
    ; shortcut in persistent storage.
    If CallCOM(#ShellLink_QueryInterface, psl, ?IID_IPersistFile, @ppf) = 0
      ; Ensure that the string is Unicode.
      mem.s = Space(1000) ; AllocateMemory(1,1000)
      MultiByteToWideChar_(#CP_ACP, 0, LINK$, - 1, mem, 1000)
      ; Save the link by calling IPersistFile::Save.
      ; hres = ppf->Save(wsz, TRUE);
      hres = CallCOM(#PersistFile_SAVE, ppf, mem, #TRUE)
      result = 1
      CallCOM(#PersistFile_Release, ppf)
      ; FreeMemory_()
    EndIf
    CallCOM(#ShellLink_Release, psl)
  EndIf
  CoUninitialize_()
  ProcedureReturn result
  
  DataSection
  CLSID_ShellLink :
  Data.l $00021401
  Data.w $0000, $0000
  Data.b $C0, $00, $00, $00, $00, $00, $00, $46
  IID_IShellLink :
  Data.l $000214EE
  Data.w $0000, $0000
  Data.b $C0, $00, $00, $00, $00, $00, $00, $46
  IID_IPersistFile :
  Data.l $0000010b
  Data.w $0000, $0000
  Data.b $C0, $00, $00, $00, $00, $00, $00, $46
  EndDataSection
  
EndProcedure



; CreateLink(PATH$, LINK$, Argument$, DESCRIPTION$, WorkingDirectory$, ShowCommand.l, HotKey.l, IconFile$, IconIndexInFile.l)
; - PATH$ = Cible du raccourci ("c:\program files\PureBasic\purebasic.exe")
; - LINK$ = Nom et emplacement du raccourci ("c:\pb.lnk")
; - Argument$ = arguments
; - DESCRIPTION$ = Description et Tooltip ("Start PureBasic")
; - WorkingDirectory$ = Répertoire de travail ("c:\program files\PureBasic\")
; - ShowCommand.l = Type d'ouverture de la fenêtre #SW_SHOWNORMAL ou #SW_SHOWMAXIMIZED ou #SW_SHOWMINIMIZED
; - HotKey.l = Touche de raccourci, mettre 0 pour aucune touche de raccourci
; - IconFile$, IconIndexInFile.l = Adresse de l'icône + Index de l'icône ( "c:\program files\PureBasic\purebasic.exe" , 0 )

If CreateLink("c:\program files\PureBasic\purebasic.exe", "c:\PB.lnk", "", "Pure FUN", "c:\program files\PureBasic\", #SW_SHOWNORMAL, 0, "c:\program files\PureBasic\purebasic.exe", 0)
  Beep_(800, 100)
EndIf