Page 1 sur 1

Et PB créa un raccourci [Resolu]

Publié : mar. 20/nov./2012 13:45
par MLD
Bonjour a tous

Ou je suis nul en recherche, ou a part un topic assez ancien je n'ai rien trouver;
Le sujet étant de pouvoir créer un raccourci sur le bureau avec PB(sans Comate) pour, par exemple faire un installeur de logiciels. (J'ai trouvé avec VBScipt), mais j'aime pas.
Alors quelqun a t'il une idée. Je pense que cela servirait a nombre d'entre nous.
Merci d'avance

Michel

Re: Et PB créa un raccourci

Publié : mar. 20/nov./2012 14:14
par nico

Re: Et PB créa un raccourci

Publié : mar. 20/nov./2012 14:31
par MLD
Merci nico

c'est de ce topic que je parlais. Il ne me semblait pas fiable a 100% :?:
Mais quelqu'un a peut être une autre idée. Car en VbSript le code est trés court.
Faute de mieux en te remerciant encore pour ce partage je ferai des tests. :lol:
Michel

Re: Et PB créa un raccourci

Publié : mar. 20/nov./2012 17:55
par Ar-S
Rien trouvé d'autre. ça m'a permis de voir que j'avais encore un vieux code obsolète.

Re: Et PB créa un raccourci

Publié : mar. 20/nov./2012 18:28
par Backup
ya aussi :roll:
mais seulement pour Windows

Code : Tout sélectionner

CreateShellLink(prg_a_lancer$,GetCurrentDirectory()+"nom_du_raccourcis.lnk","","Merci Danilo",lieu_de_travail$,#SW_SHOWNORMAL,0,"%SystemRoot%\system32\SHELL32.dll",12)

Procedure CreateShellLink(path$, LINK$, Argument$, DESCRIPTION$, WorkingDirectory$, ShowCommand.l, HotKey.l, IconFile$, IconIndexInFile.l)
	
	; CreateLink
	;             - TARGET$ for the Link ("c:\PureBasic\purebasic.exe")
	;             - LINK$ - name of the Link ("c:\pb.lnk")
	;             - Argument$ for the target  ("%1")
	;             - Description$ = Description and Tooltip ("Start PureBasic")
	;             - Working Directory ("c:\PureBasic\")
	;             - Show command: #SW_SHOWNORMAL or #SW_SHOWMAXIMIZED or #SW_SHOWMINIMIZED
	;             - HotKey - no need to use this :)
	;             - IconFile + Index ( "c:\PureBasic\purebasic.exe" , 1 )
	
	CoInitialize_(0)
	If CoCreateInstance_(?CLSID_ShellLink,0,1,?IID_IShellLink,@psl.IShellLinkA) = 0
	
	Set_ShellLink_preferences:
	
	; The file TO which is linked ( = target for the Link )
	;
	psl\SetPath(@path$)
	
	; Arguments for the Target
	;
	psl\SetArguments(@Argument$)
	
	; Working Directory
	;
	psl\SetWorkingDirectory(@WorkingDirectory$)
	
	; Description ( also used as Tooltip for the Link )
	;
	psl\SetDescription(@DESCRIPTION$)
	
	; Show command:
	;               SW_SHOWNORMAL    = Default
	;               SW_SHOWMAXIMIZED = aehmm... Maximized
	;               SW_SHOWMINIMIZED = play Unreal Tournament
	psl\SetShowCmd(ShowCommand)
	
	; Hotkey:
	; The virtual key code is in the low-order byte,
	; and the modifier flags are in the high-order byte.
	; The modifier flags can be a combination of the following values:
	;
	;         HOTKEYF_ALT     = ALT key
	;         HOTKEYF_CONTROL = CTRL key
	;         HOTKEYF_EXT     = Extended key
	;         HOTKEYF_SHIFT   = SHIFT key
	;
	psl\SetHotkey(HotKey)
	
	; Set Icon for the Link:
	; There can be more than 1 icons in an icon resource file,
	; so you have to specify the index.
	;
	psl\SetIconLocation(@IconFile$, IconIndexInFile)
	
	
	ShellLink_SAVE:
	; Query IShellLink For the IPersistFile interface For saving the
	; shortcut in persistent storage.
	If psl\QueryInterface(?IID_IPersistFile,@ppf.IPersistFile) = 0
	; Ensure that the string is Unicode.
	mem.S = Space(1000) ;AllocateMemory(1,1000)
	MultiByteToWideChar_(#CP_ACP, 0, LINK$, -1, mem, 1000)
	;Save the link by calling IPersistFile::Save.
	hres = ppf\Save(@mem,#True)
	Result = 1
	ppf\Release()
	EndIf
	psl\Release()
	EndIf
	CoUninitialize_()
	ProcedureReturn Result
	
	DataSection
	CLSID_ShellLink:
	; 00021401-0000-0000-C000-000000000046
	Data.l $00021401
	Data.w $0000,$0000
	Data.B $C0,$00,$00,$00,$00,$00,$00,$46
	IID_IShellLink:
	; DEFINE_SHLGUID(IID_IShellLinkA,         0x000214EEL, 0, 0);
	; C000-000000000046
	Data.l $000214EE
	Data.w $0000,$0000
	Data.B $C0,$00,$00,$00,$00,$00,$00,$46
	IID_IPersistFile:
	; 0000010b-0000-0000-C000-000000000046
	Data.l $0000010B
	Data.w $0000,$0000
	Data.B $C0,$00,$00,$00,$00,$00,$00,$46
	EndDataSection
	
EndProcedure

Re: Et PB créa un raccourci [ Resolu ]

Publié : mer. 21/nov./2012 10:17
par MLD
Merci Dobro