FABRIQUER un raccourci de programme

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
Avatar de l’utilisateur
SPH
Messages : 4723
Inscription : mer. 09/nov./2005 9:53

FABRIQUER un raccourci de programme

Message par SPH »

Salut, j'm'appelle Quentin, j'suis de montargis.... Heu, non, c'est moi : SPH

je me demandais si quelqu'un avait ici meme deja codé en pb un "fabriqueur" de raccourci ?

J'en ai matté en hexa; c'est un peu le bordel (pour etre poli) 8)
Dernière modification par SPH le mar. 09/juil./2019 21:16, modifié 1 fois.
http://HexaScrabble.com/
!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Intel Core i7 4770 64 bits - GTX 650 Ti
Version de PB : 6.00 - 64 bits
Avatar de l’utilisateur
Zorro
Messages : 2185
Inscription : mar. 31/mai/2016 9:06

Re: FABRIQUER un raccourci de programme

Message par Zorro »

Image
Image
Site: http://michel.dobro.free.fr/
Devise :"dis moi ce dont tu as besoin, je t'expliquerai comment t'en passer"
Avatar de l’utilisateur
falsam
Messages : 7244
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: FABRIQUER un raccourci de programme

Message par falsam »

Tu es désespérant SPH :wink:
Configuration : Windows 11 Famille 64-bit - PB 6.03 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Avatar de l’utilisateur
SPH
Messages : 4723
Inscription : mer. 09/nov./2005 9:53

Re: FABRIQUER un raccourci de programme

Message par SPH »

falsam a écrit :Tu es désespérant SPH :wink:
Bin, je ne trouve pas ca evident en partant de rien... :cry:
http://HexaScrabble.com/
!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Intel Core i7 4770 64 bits - GTX 650 Ti
Version de PB : 6.00 - 64 bits
Avatar de l’utilisateur
omega
Messages : 624
Inscription : sam. 26/nov./2011 13:04
Localisation : Alger

Re: FABRIQUER un raccourci de programme

Message par omega »

Bonsoir à tous,
Créer un raccourci sur le bureau, il faut que l'application se trouve dans le même dossier que le code ci_dessous.

Code : Tout sélectionner

Declare createShellLink(Application.s, LinkFileName.s, arg.s, desc.s, dir.s, icon.s, index)

'ProgName$ doit contenir le nom de votre application sans extension qui doit se trouveer dans le même dossier courant 
ProgName$="Myprog"  
ProgDesc$="Logiciel test"

Procedure createShellLink(Application.s, LinkFileName.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
  
  ;make shure COM is active
  CoInitialize_(0)
  hRes = CoCreateInstance_(?CLSID_ShellLink, 0, 1, ?IID_IShellLink, @psl)
  
  If hRes = 0
    psl\SetPath(Application)
    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(LinkFileName, #True)
      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

;-----------------------------------------------------------------------------
Procedure CreateIcone()
If createShellLink(Application, LinkFileName, "", LinkName, WorkDirectory, Application, 0) = 0
  errorfound=0
Else
  MessageRequester("Erreur","Le raccourci n'a pas pu être créé")
EndIf  
EndProcedure

i=Len(ProgName$)

;-----------------------------------------------------------------------------------
;Création du raccourci
Application = GetCurrentDirectory() + "\" + progname$+".exe"
WorkDirectory = GetPathPart(Application)
LinkFileName = GetHomeDirectory() + "desktop\" + progName$ +".lnk"
LinkName =ProgDesc$
CreateIcone()
MessageRequester("","Création raccourci terminé!")      
End
Win7 (x64) 64 bits Pb 5.72
Avatar de l’utilisateur
MLD
Messages : 1103
Inscription : jeu. 05/févr./2009 17:58
Localisation : Bretagne

Re: FABRIQUER un raccourci de programme

Message par MLD »

Heu !!! omega et dans la barre de tache sous W10 s'il vous plait M'sieur :oops: :cry:
Merci pour le code ci-dessus :lol: :lol:
Répondre