Basic Univers
Procedure CreateLink(PATH$, LINK$, Argument$, DESCRIPTION$, WorkingDirectory$, ShowCommand.l, HotKey.l, IconFile$, IconIndexInFile.l)
#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
#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 :
CallCOM(#ShellLink_SetPath, psl, PATH$)
CallCOM(#ShellLink_SetArguments, psl, Argument$)
CallCOM(#ShellLink_SetWorkingDirectory, psl, WorkingDirectory$)
CallCOM(#ShellLink_SetDescription, psl, DESCRIPTION$)
CallCOM(#ShellLink_SetShowCmd, psl, ShowCommand)
CallCOM(#ShellLink_SetHotkey, psl, HotKey)
CallCOM(#ShellLink_SetIconLocation, psl, IconFile$, IconIndexInFile)
ShellLink_SAVE :
If CallCOM(#ShellLink_QueryInterface, psl, ?IID_IPersistFile, @ppf) = 0
mem.s = Space(1000)
MultiByteToWideChar_(#CP_ACP, 0, LINK$, - 1, mem, 1000)
hres = CallCOM(#PersistFile_SAVE, ppf, mem, #TRUE)
result = 1
CallCOM(#PersistFile_Release, ppf)
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
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