Page 1 sur 1

FABRIQUER un raccourci de programme

Publié : lun. 08/juil./2019 23:54
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)

Re: FABRIQUER un raccourci de programme

Publié : mar. 09/juil./2019 7:35
par Zorro

Re: FABRIQUER un raccourci de programme

Publié : mar. 09/juil./2019 17:52
par falsam
Tu es désespérant SPH :wink:

Re: FABRIQUER un raccourci de programme

Publié : mar. 09/juil./2019 21:17
par SPH
falsam a écrit :Tu es désespérant SPH :wink:
Bin, je ne trouve pas ca evident en partant de rien... :cry:

Re: FABRIQUER un raccourci de programme

Publié : mer. 10/juil./2019 23:06
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

Re: FABRIQUER un raccourci de programme

Publié : jeu. 11/juil./2019 9:48
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: