You will need Admin rights
And do not use Explorer Sendto ,use the next snippet
Code: Select all
Global obj.s, lnk.s
Procedure.s GetSpecialFolder(id)
Protected path.s, *ItemId.ITEMIDLIST
*itemId = #Null
If SHGetSpecialFolderLocation_(0, id, @*ItemId) = #NOERROR
path = Space(#MAX_PATH)
If SHGetPathFromIDList_(*itemId, @path)
If Right(path, 1) <> "\"
path + "\"
EndIf
ProcedureReturn path
EndIf
EndIf
ProcedureReturn ""
EndProcedure
Procedure CreateShellLink(obj.s, lnk.s, arg.s, desc.s, dir.s, icon.s, index)
Protected hRes.l, mem.s, ppf.IPersistFile
CompilerIf #PB_Compiler_Unicode
Protected psl.IShellLinkW
CompilerElse
Protected psl.IShellLinkA
CompilerEndIf
CoInitialize_(0)
hRes = CoCreateInstance_(?CLSID_ShellLink, 0, 1, ?IID_IShellLink, @psl)
If hRes = 0
psl\SetPath(Obj)
psl\SetArguments(arg)
psl\SetDescription(desc)
psl\SetWorkingDirectory(dir)
psl\SetIconLocation(icon, index)
hRes = psl\QueryInterface(?IID_IPersistFile, @ppf)
If hRes = 0
hRes = ppf\Save(lnk, #True)
ppf\Release()
EndIf
psl\Release()
EndIf
CoUninitialize_()
DataSection
CLSID_ShellLink:
Data.l $00021401
Data.w $0000,$0000
Data.b $C0,$00,$00,$00,$00,$00,$00,$46
IID_IShellLink:
CompilerIf #PB_Compiler_Unicode
Data.l $000214F9
CompilerElse
Data.l $000214EE
CompilerEndIf
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
ProcedureReturn hRes
EndProcedure
#CSIDL_WINDOWS = $24
#CSIDL_DESKTOPDIRECTORY = $10
obj = "c:\MMR Sound Player\Sound Player.exe"
llnk.s = GetFilePart(obj,#PB_FileSystem_NoExtension)
lnk = GetSpecialFolder(#CSIDL_DESKTOPDIRECTORY) + llnk+".lnk"
If createShellLink(obj, lnk, "", "", "C:\", obj, 0) = 0
MessageRequester("OK", "Link created on the desktop", #PB_MessageRequester_Ok)
EndIf
End