Bonjour
Je cherche a creer un raccourci sur le bureau comme le font les programmes d'instalations.
est ce qu'il faut inclure un compilateur et compiler le raccourci? ou il y a une autre facon?
merci
creer raccourci sur le bureau
creer raccourci sur le bureau
Windows 10 x64 -- Purebasic 5.70 LTS x86
Re: creer raccourci sur le bureau
en fait ca ne marche pas, ca retourne un message d'erreur a la ligne 45
Windows 10 x64 -- Purebasic 5.70 LTS x86
Re: creer raccourci sur le bureau
tu as des reponses ici , qui fonctionne 
http://forums.purebasic.com/english/vie ... a8d1e49992
exemple de code : (j'ai pas fait le tour, il y a d'autres code ! )
ça c'est la correction du code de tout a l'heure par Rashad ; tourne sous Pb 5.50

http://forums.purebasic.com/english/vie ... a8d1e49992
exemple de code : (j'ai pas fait le tour, il y a d'autres code ! )

ça c'est la correction du code de tout a l'heure par Rashad ; tourne sous Pb 5.50
Code : Tout sélectionner
;PB4.00
;20061127, now works with unicode executables
EnableExplicit
Declare createShellLink(obj.s, lnk.s, arg.s, desc.s, dir.s, icon.s, index)
Declare.s getSpecialFolder(id)
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)
;obj - path to the exe that is linked to, lnk - link name, dir - working
;directory, icon - path to the icon file, index - icon index in iconfile
Protected hRes.l, mem.s, ppf.IPersistFile
CompilerIf #PB_Compiler_Unicode
Protected psl.IShellLinkW
CompilerElse
Protected psl.IShellLinkA
CompilerEndIf
;make shure COM is active
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)
;query IShellLink for the IPersistFile interface for saving the
;link in persistent storage
hRes = psl\QueryInterface(?IID_IPersistFile, @ppf)
If hRes = 0
;CompilerIf #PB_Compiler_Unicode
;save the link
hRes = ppf\Save(lnk, #True)
; CompilerElse
; ;ensure that the string is ansi unicode
; mem = Space(#MAX_PATH)
; MultiByteToWideChar_(#CP_ACP, 0, lnk, -1, mem, #MAX_PATH)
; ;save the link
; hRes = ppf\Save(mem, #True)
; CompilerEndIf
ppf\Release()
EndIf
psl\Release()
EndIf
;shut down COM
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
Global obj.s, lnk.s
obj = getSpecialFolder(#CSIDL_WINDOWS) + "Notepad.exe"
lnk = getSpecialFolder(#CSIDL_DESKTOPDIRECTORY) + "Demo link.lnk"
If createShellLink(obj, lnk, "", "Open Notepad", "C:\", obj, 0) = 0
MessageRequester("OK", "Link created on the desktop", #PB_MessageRequester_Ok)
EndIf
End