;Autor: Danilo, ts-soft ;http://www.purebasic.fr/german/viewtopic.php?p=337003#p337003 EnableExplicit Procedure.s spec_folder(clsi_const.l) Protected path.s = Space(2048) Protected pidl.l SHGetSpecialFolderLocation_(0,clsi_const,@pidl.l) SHGetPathFromIDList_(pidl,@path) CoTaskMemFree_(pidl) ProcedureReturn path+"\" EndProcedure Macro DEFINE_GUID(Name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) CompilerIf Defined(Name, #PB_Variable) If SizeOf(Name) = SizeOf(GUID) Name\Data1 = l Name\Data2 = w1 Name\Data3 = w2 Name\Data4[0] = b1 Name\Data4[1] = b2 Name\Data4[2] = b3 Name\Data4[3] = b4 Name\Data4[4] = b5 Name\Data4[5] = b6 Name\Data4[6] = b7 Name\Data4[7] = b8 Else Debug "Error - variable not declared as guid" EndIf CompilerEndIf EndMacro Procedure CreateShortcut(Path.s, Link.s, WorkingDir.s = "", Argument.s = "", ShowCommand.l = #SW_SHOWNORMAL, Description.s = "", HotKey.l = #Null, IconFile.s = "|", IconIndex.l = 0) Protected psl.IShellLinkW, ppf.IPersistFile, Result Protected.GUID CLSID_ShellLink, IID_IShellLink, IID_IPersistFile DEFINE_GUID(CLSID_ShellLink, $00021401, $0000,$0000, $C0, $00, $00, $00, $00, $00, $00, $46) ; {00021401-0000-0000-C000-000000000046} DEFINE_GUID(IID_IShellLink, $000214F9, $0000,$0000, $C0, $00, $00, $00, $00, $00, $00, $46) ; {000214F9-0000-0000-C000-000000000046} DEFINE_GUID(IID_IPersistFile, $0000010B, $0000,$0000, $C0, $00, $00, $00, $00, $00, $00, $46); {0000010b-0000-0000-C000-000000000046} If IconFile = "|" : IconFile = Path : EndIf If WorkingDir = "" : WorkingDir = GetPathPart(Path) : EndIf CoInitialize_(0) If CoCreateInstance_(@CLSID_ShellLink, 0, 1, @IID_IShellLink, @psl) = #S_OK Set_ShellLink_preferences: psl\SetPath(Path) psl\SetArguments(Argument) psl\SetWorkingDirectory(WorkingDir) psl\SetDescription(DESCRIPTION) psl\SetShowCmd(ShowCommand) psl\SetHotkey(HotKey) psl\SetIconLocation(IconFile, IconIndex) ShellLink_SAVE: If psl\QueryInterface(@IID_IPersistFile, @ppf) = #S_OK ppf\Save(Link, #True) result = 1 ppf\Release() EndIf psl\Release() EndIf CoUninitialize_() ProcedureReturn result EndProcedure CreateShortcut("notepad.exe", "D:\MyLink.lnk") ; IDE Options = PureBasic 5.31 (Windows - x64) ; Folding = - ; EnableXP ; EnableUser ; EnableCompileCount = 1 ; EnableBuildCount = 0