View Single Post
  #2  
Old 06-03-2017, 07:32
Gupta Gupta is offline
Banned
 
Join Date: Aug 2016
Location: https://t.me/pump_upp
Posts: 399
Thanks: 139
Thanked 715 Times in 231 Posts
Gupta is on a distinguished road
Send a message via ICQ to Gupta Send a message via AIM to Gupta Send a message via Yahoo to Gupta
How to add unlimited shortcuts from an ini?

Code:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define public ShortcutsINI ".\\Shortcuts.ini"

[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application

[Icons]
#ifnexist ShortCutsINI
  #error Ini doesn't Exists
#endif
#define public Counter
#define public i
#define public Section

#expr Counter = 0
#define public ExeName
#define public ExeFile
#define public ExeGroupFile
#define public ExeParameters
#define public ExeWorkingDir
#define public ExeComment
#define public ExeIconFileName
#define public ExeFlags
#sub AddIcons
  #expr Counter = Counter + 1
  #expr Section = StringChange( "ExeCounter", "Counter", str(Counter) )
  #expr ExeName = ReadIni (SourcePath + ShortcutsINI , Section, "Name")
  #expr Exefile = Readini  (SourcePath + ShortcutsINI , Section, "File")
  #expr ExeParameters = Readini  (SourcePath + ShortcutsINI , Section, "Parameters","")
  #expr ExeWorkingDir = Readini  (SourcePath + ShortcutsINI , Section, "WorkingDir","{app}")
  #expr ExeComment = Readini  (SourcePath + ShortcutsINI , Section, "Comment","Play")
  #expr ExeIconFileName = Readini  (SourcePath + ShortcutsINI , Section, "IconFileName","")
  #expr ExeFlags = Readini  (SourcePath + ShortcutsINI , Section, "Flags","")
  #if ReadIni(SourcePath + ShortcutsINI, Section, "GroupShortCut","0") != "0"
    #expr ExeGroupFile = Readini(SourcePath + ShortcutsINI , Section, "GroupIconName","")
    Name: "{group}\{#ExeGroupFile}"; Filename:"{#ExeFile}"; Parameters: "{#ExeParameters}" ; WorkingDir: "{#ExeWorkingDir}" ; Comment: "{#ExeComment}" ; IconFilename: "{#ExeIconFileName}" ; Flags: {#ExeFlags}  ; 
  #endif
  Name: "{userdesktop}\{#ExeName}"; Filename: "{#ExeFile}"; Parameters: "{#ExeParameters}" ; WorkingDir: "{#ExeWorkingDir}"; Comment: "{#ExeComment}" ; IconFilename: "{#ExeIconFileName}" ; Flags: {#ExeFlags}  ; 
#endsub
#for { i = 1 ; ReadIni( SourcePath + ShortcutsINI, StringChange( "ExeCounter", "Counter", str(i)) , "Name" , "" ) != "" ; i++ } AddIcons
Ini Structure Should be:
Code:
[Exe1]
Name=Play - Some game
File={app}\SomeExecutable
Parameters=/play filename.mid
WorkingDir={app}
Comment=This is my program
IconFileName={app}\myicon.ico
;Flags=createonlyiffileexists
GroupShortCut=0
GroupIconName=SomeExecutableName

[Exe2]
Name=Play - Some game2
File={app}\SomeExecutable
Parameters=/play filename.mid
WorkingDir={app}
Comment=This is my program
IconFileName={app}\myicon.ico
;Flags=createonlyiffileexists
GroupShortCut=0
GroupIconName=SomeExecutableName

[Exe3]
Name=Play - Some game3
File={app}\SomeExecutable
Parameters=/play filename.mid
WorkingDir={app}
Comment=This is my program
IconFileName={app}\myicon.ico
;Flags=createonlyiffileexists
GroupShortCut=0
GroupIconNameSomeExecutableName

[Exe4]
Name=Play - Some game4
File={app}\SomeExecutable
Parameters=/play filename.mid
WorkingDir={app}
Comment=This is my program
IconFileName={app}\myicon.ico
;Flags=createonlyiffileexists
GroupShortCut=0
GroupIconName=SomeExecutableName
I wrote this Myselef
Reply With Quote
The Following 5 Users Say Thank You to Gupta For This Useful Post:
Cesar82 (28-03-2017), EzzEldin16 (05-01-2018), Razor12911 (14-03-2017), TWOELV (13-03-2017), Viper645 (10-03-2017)