IDE.Wizard.WizardForm.pas 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095
  1. unit IDE.Wizard.WizardForm;
  2. {
  3. Inno Setup
  4. Copyright (C) 1997-2024 Jordan Russell
  5. Portions by Martijn Laan
  6. For conditions of distribution and use, see LICENSE.TXT.
  7. Compiler IDE Script Wizard form
  8. }
  9. interface
  10. uses
  11. Windows, Forms, Classes, Graphics, StdCtrls, ExtCtrls, Controls, Dialogs, pngimage,
  12. UIStateForm, NewStaticText, DropListBox, NewCheckListBox, NewNotebook,
  13. IDE.Wizard.WizardFormFilesHelper, IDE.Wizard.WizardFormRegistryHelper;
  14. type
  15. TWizardPage = (wpWelcome, wpAppInfo, wpAppDir, wpAppFiles, wpAppAssoc, wpAppIcons,
  16. wpAppDocs, wpPrivilegesRequired, wpAppRegistry, wpLanguages, wpCompiler,
  17. wpISPP, wpFinished);
  18. TWizardFormResult = (wrNone, wrEmpty, wrComplete);
  19. TWizardForm = class(TUIStateForm)
  20. CancelButton: TButton;
  21. NextButton: TButton;
  22. BackButton: TButton;
  23. OuterNotebook: TNewNotebook;
  24. InnerNotebook: TNewNotebook;
  25. WelcomePage: TNewNotebookPage;
  26. MainPage: TNewNotebookPage;
  27. AppInfoPage: TNewNotebookPage;
  28. AppDirPage: TNewNotebookPage;
  29. AppFilesPage: TNewNotebookPage;
  30. AppIconsPage: TNewNotebookPage;
  31. AppDocsPage: TNewNotebookPage;
  32. PrivilegesRequiredPage: TNewNotebookPage;
  33. AppRegistryPage: TNewNotebookPage;
  34. LanguagesPage: TNewNotebookPage;
  35. CompilerPage: TNewNotebookPage;
  36. ISPPPage: TNewNotebookPage;
  37. FinishedPage: TNewNotebookPage;
  38. Bevel: TBevel;
  39. WelcomeImage: TImage;
  40. WelcomeLabel1: TNewStaticText;
  41. PnlMain: TPanel;
  42. Bevel1: TBevel;
  43. PageNameLabel: TNewStaticText;
  44. PageDescriptionLabel: TNewStaticText;
  45. InnerImage: TImage;
  46. FinishedLabel: TNewStaticText;
  47. FinishedImage: TImage;
  48. WelcomeLabel2: TNewStaticText;
  49. EmptyCheck: TCheckBox;
  50. WelcomeLabel3: TNewStaticText;
  51. AppNameLabel: TNewStaticText;
  52. AppNameEdit: TEdit;
  53. AppVersionLabel: TNewStaticText;
  54. AppVersionEdit: TEdit;
  55. AppDirNameLabel: TNewStaticText;
  56. AppRootDirComboBox: TComboBox;
  57. AppRootDirEdit: TEdit;
  58. AppDirNameEdit: TEdit;
  59. NotDisableDirPageCheck: TCheckBox;
  60. AppRootDirLabel: TNewStaticText;
  61. AppPublisherLabel: TNewStaticText;
  62. AppPublisherEdit: TEdit;
  63. OtherLabel: TNewStaticText;
  64. NotCreateAppDirCheck: TCheckBox;
  65. AppFilesLabel: TNewStaticText;
  66. AppFilesListBox: TDropListBox;
  67. AppFilesAddButton: TButton;
  68. AppFilesEditButton: TButton;
  69. AppFilesRemoveButton: TButton;
  70. AppURLLabel: TNewStaticText;
  71. AppURLEdit: TEdit;
  72. AppExeLabel: TNewStaticText;
  73. AppExeEdit: TEdit;
  74. AppExeRunCheck: TCheckBox;
  75. AppExeButton: TButton;
  76. AppGroupNameLabel: TNewStaticText;
  77. AppGroupNameEdit: TEdit;
  78. NotDisableProgramGroupPageCheck: TCheckBox;
  79. AllowNoIconsCheck: TCheckBox;
  80. AppExeIconsLabel: TNewStaticText;
  81. DesktopIconCheck: TCheckBox;
  82. CreateUninstallIconCheck: TCheckBox;
  83. CreateURLIconCheck: TCheckBox;
  84. AppLicenseFileLabel: TNewStaticText;
  85. AppLicenseFileEdit: TEdit;
  86. AppLicenseFileButton: TButton;
  87. AppInfoBeforeFileLabel: TNewStaticText;
  88. AppInfoBeforeFileEdit: TEdit;
  89. AppInfoBeforeFileButton: TButton;
  90. AppInfoAfterFileLabel: TNewStaticText;
  91. AppInfoAfterFileEdit: TEdit;
  92. AppInfoAfterFileButton: TButton;
  93. RequiredLabel1: TNewStaticText;
  94. RequiredLabel2: TNewStaticText;
  95. AppFilesAddDirButton: TButton;
  96. ISPPCheck: TCheckBox;
  97. ISPPLabel: TLabel;
  98. OutputDirLabel: TNewStaticText;
  99. OutputDirEdit: TEdit;
  100. OutputBaseFileNameLabel: TNewStaticText;
  101. OutputBaseFileNameEdit: TEdit;
  102. SetupIconFileLabel: TNewStaticText;
  103. SetupIconFileEdit: TEdit;
  104. PasswordLabel: TNewStaticText;
  105. PasswordEdit: TEdit;
  106. SetupIconFileButton: TButton;
  107. EncryptionCheck: TCheckBox;
  108. OutputDirButton: TButton;
  109. LanguagesLabel: TNewStaticText;
  110. LanguagesList: TNewCheckListBox;
  111. AllLanguagesButton: TButton;
  112. NoLanguagesButton: TButton;
  113. NoAppExeCheck: TCheckBox;
  114. UseAutoProgramsCheck: TCheckBox;
  115. PrivilegesRequiredLabel: TNewStaticText;
  116. PrivilegesRequiredAdminRadioButton: TRadioButton;
  117. PrivilegesRequiredLowestRadioButton: TRadioButton;
  118. PrivilegesRequiredOverridesAllowedCommandLineCheckbox: TCheckBox;
  119. PrivilegesRequiredOverridesAllowedDialogCheckbox: TCheckBox;
  120. AppAssocPage: TNewNotebookPage;
  121. AppAssocNameEdit: TEdit;
  122. AppAssocNameLabel: TNewStaticText;
  123. CreateAssocCheck: TCheckBox;
  124. AppAssocExtLabel: TNewStaticText;
  125. AppAssocExtEdit: TEdit;
  126. AppRegistryFileLabel: TNewStaticText;
  127. AppRegistryFileEdit: TEdit;
  128. AppRegistryFileButton: TButton;
  129. AppRegistrySettingsLabel: TNewStaticText;
  130. AppRegistryUninsDeleteKeyCheck: TCheckBox;
  131. AppRegistryUninsDeleteKeyIfEmptyCheck: TCheckBox;
  132. AppRegistryUninsDeleteValueCheck: TCheckBox;
  133. AppRegistryMinVerCheck: TCheckBox;
  134. AppRegistryMinVerEdit: TEdit;
  135. AppRegistryMinVerDocImage: TImage;
  136. procedure FormCreate(Sender: TObject);
  137. procedure FormShow(Sender: TObject);
  138. procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  139. procedure FormDestroy(Sender: TObject);
  140. procedure NextButtonClick(Sender: TObject);
  141. procedure BackButtonClick(Sender: TObject);
  142. procedure FileButtonClick(Sender: TObject);
  143. procedure AppRootDirComboBoxChange(Sender: TObject);
  144. procedure NotCreateAppDirCheckClick(Sender: TObject);
  145. procedure AppExeButtonClick(Sender: TObject);
  146. procedure NotDisableProgramGroupPageCheckClick(Sender: TObject);
  147. procedure PasswordEditChange(Sender: TObject);
  148. procedure OutputDirButtonClick(Sender: TObject);
  149. procedure AllLanguagesButtonClick(Sender: TObject);
  150. procedure NoLanguagesButtonClick(Sender: TObject);
  151. procedure NoAppExeCheckClick(Sender: TObject);
  152. procedure UseAutoProgramsCheckClick(Sender: TObject);
  153. procedure PrivilegesRequiredOverridesAllowedDialogCheckboxClick(Sender: TObject);
  154. procedure CreateAssocCheckClick(Sender: TObject);
  155. private
  156. CurPage: TWizardPage;
  157. FWizardName: String;
  158. FFilesHelper: TWizardFormFilesHelper;
  159. FRegistryHelper: TWizardFormRegistryHelper;
  160. FLanguages: TStringList;
  161. FResult: TWizardFormResult;
  162. FResultScript: String;
  163. function FixLabel(const S: String): String;
  164. procedure SetWizardName(const WizardName: String);
  165. procedure CurPageChanged;
  166. function SkipCurPage: Boolean;
  167. procedure UpdateAppExeControls;
  168. procedure UpdateAppAssocControls;
  169. procedure UpdateAppIconsControls;
  170. procedure GenerateScript;
  171. public
  172. property WizardName: String write SetWizardName;
  173. property Result: TWizardFormResult read FResult;
  174. property ResultScript: String read FResultScript;
  175. end;
  176. implementation
  177. {$R *.DFM}
  178. uses
  179. SysUtils, ShlObj, ActiveX, UITypes, Shared.FileClass,
  180. PathFunc, Shared.CommonFunc.Vcl, Shared.CommonFunc, IDE.HelperFunc, BrowseFunc,
  181. IDE.Messages, IDE.Wizard.WizardFileForm;
  182. type
  183. TConstant = record
  184. Constant, Description: String;
  185. end;
  186. const
  187. NotebookPages: array[TWizardPage, 0..1] of Integer =
  188. ((0, -1), (1, 0), (1, 1), (1, 2),
  189. (1, 3), (1, 4), (1, 5), (1, 6),
  190. (1, 7), (1, 8), (1, 9), (1, 10), (2, -1));
  191. PageCaptions: array[TWizardPage] of String =
  192. (SWizardWelcome, SWizardAppInfo, SWizardAppDir, SWizardAppFiles, SWizardAppAssoc,
  193. SWizardAppIcons, SWizardAppDocs, SWizardPrivilegesRequired, SWizardAppRegistry,
  194. SWizardLanguages, SWizardCompiler, SWizardISPP, SWizardFinished);
  195. PageDescriptions: array[TWizardPage] of String =
  196. ('', SWizardAppInfo2, SWizardAppDir2, SWizardAppFiles2, SWizardAppAssoc2,
  197. SWizardAppIcons2, SWizardAppDocs2, SWizardPrivilegesRequired2, SWizardAppRegistry2,
  198. SWizardLanguages2, SWizardCompiler2, SWizardISPP2, '');
  199. RequiredLabelVisibles: array[TWizardPage] of Boolean =
  200. (False, True, True, True, True, True, False, True, False, True, False, False, False);
  201. AppRootDirs: array[0..0] of TConstant =
  202. (
  203. ( Constant: '{autopf}'; Description: 'Program Files folder')
  204. );
  205. LanguagesDefaultIsl = 'Default.isl';
  206. LanguagesDefaultIslDescription = 'English';
  207. EnabledColors: array[Boolean] of TColor = (clBtnFace, clWindow);
  208. function EscapeAmpersands(const S: String): String;
  209. begin
  210. Result := S;
  211. StringChangeEx(Result, '&', '&&', True);
  212. end;
  213. function TWizardForm.FixLabel(const S: String): String;
  214. begin
  215. Result := S;
  216. {don't localize these}
  217. StringChange(Result, '[name]', FWizardName);
  218. end;
  219. procedure TWizardForm.SetWizardName(const WizardName: String);
  220. begin
  221. FWizardName := WizardName;
  222. end;
  223. { --- }
  224. procedure TWizardForm.FormCreate(Sender: TObject);
  225. procedure AddLanguages(const Extension: String);
  226. var
  227. SearchRec: TSearchRec;
  228. begin
  229. if FindFirst(PathExtractPath(NewParamStr(0)) + 'Languages\*.' + Extension, faAnyFile, SearchRec) = 0 then begin
  230. repeat
  231. FLanguages.Add(SearchRec.Name);
  232. until FindNext(SearchRec) <> 0;
  233. FindClose(SearchRec);
  234. end;
  235. end;
  236. procedure MakeBold(const Ctl: TNewStaticText);
  237. begin
  238. Ctl.Font.Style := [fsBold];
  239. end;
  240. function SpaceLanguageName(const LanguageName: String): String;
  241. var
  242. I: Integer;
  243. begin
  244. Result := '';
  245. for I := 1 to Length(LanguageName) do begin
  246. if (I <> 1) and CharInSet(LanguageName[I], ['A'..'Z']) then
  247. Result := Result + ' ';
  248. Result := Result + LanguageName[I];
  249. end;
  250. end;
  251. var
  252. I: Integer;
  253. begin
  254. FResult := wrNone;
  255. FWizardName := SWizardDefaultName;
  256. FFilesHelper := TWizardFormFilesHelper.Create(Self,
  257. NotCreateAppDirCheck, AppFilesListBox, AppFilesAddButton, AppFilesAddDirButton,
  258. AppFilesEditButton, AppFilesRemoveButton);
  259. FRegistryHelper := TWizardFormRegistryHelper.Create(Self, AppRegistryFileEdit,
  260. AppRegistryFileButton, AppRegistryUninsDeleteKeyCheck,
  261. AppRegistryUninsDeleteKeyIfEmptyCheck, AppRegistryUninsDeleteValueCheck,
  262. AppRegistryMinVerCheck, AppRegistryMinVerEdit, AppRegistryMinVerDocImage);
  263. FLanguages := TStringList.Create;
  264. FLanguages.Sorted := True;
  265. FLanguages.Duplicates := dupIgnore; { Some systems also return .islu files when searching for *.isl }
  266. AddLanguages('isl');
  267. AddLanguages('islu');
  268. FLanguages.Sorted := False;
  269. FLanguages.Insert(0, LanguagesDefaultIsl);
  270. InitFormFont(Self);
  271. if Font.Name = 'Segoe UI' then begin
  272. { See Setup.WizardForm.pas }
  273. for I := 0 to OuterNotebook.PageCount-1 do
  274. OuterNotebook.Pages[I].HandleNeeded;
  275. for I := 0 to InnerNotebook.PageCount-1 do
  276. InnerNotebook.Pages[I].HandleNeeded;
  277. ClientWidth := MulDiv(ClientWidth, 105, 100);
  278. end;
  279. if FontExists('Verdana') then
  280. WelcomeLabel1.Font.Name := 'Verdana';
  281. OuterNotebook.Color := clWindow;
  282. MakeBold(PageNameLabel);
  283. MakeBold(RequiredLabel1);
  284. MakeBold(AppNameLabel);
  285. MakeBold(AppVersionLabel);
  286. MakeBold(AppRootDirLabel);
  287. MakeBold(AppDirNameLabel);
  288. MakeBold(AppExeLabel);
  289. MakeBold(AppAssocNameLabel);
  290. MakeBold(AppAssocExtLabel);
  291. MakeBold(AppGroupNameLabel);
  292. MakeBold(PrivilegesRequiredLabel);
  293. MakeBold(LanguagesLabel);
  294. FinishedImage.Picture := WelcomeImage.Picture;
  295. RequiredLabel2.Left := RequiredLabel1.Left + RequiredLabel1.Width;
  296. { AppInfo }
  297. AppNameEdit.Text := 'My Program';
  298. AppVersionEdit.Text := '1.5';
  299. AppPublisherEdit.Text := 'My Company, Inc.';
  300. AppURLEdit.Text := 'https://www.example.com/';
  301. { AppDir }
  302. for I := Low(AppRootDirs) to High(AppRootDirs) do
  303. AppRootDirComboBox.Items.Add(AppRootDirs[I].Description);
  304. AppRootDirComboBox.Items.Add('(Custom)');
  305. AppRootDirComboBox.ItemIndex := 0;
  306. AppRootDirEdit.Enabled := False;
  307. AppRootDirEdit.Color := clBtnFace;
  308. NotDisableDirPageCheck.Checked := True;
  309. { AppFiles }
  310. AppExeEdit.Text := PathExtractPath(NewParamStr(0)) + 'Examples\MyProg-x64.exe';
  311. AppExeRunCheck.Checked := True;
  312. { AppAssoc }
  313. CreateAssocCheck.Checked := True;
  314. AppAssocExtEdit.Text := '.myp';
  315. { AppIcons }
  316. UseAutoProgramsCheck.Checked := True;
  317. NotDisableProgramGroupPageCheck.Checked := True;
  318. DesktopIconCheck.Checked := True;
  319. { PrivilegesRequired }
  320. PrivilegesRequiredAdminRadioButton.Checked := True;
  321. { Languages }
  322. for I := 0 to FLanguages.Count-1 do begin
  323. if FLanguages[I] <> LanguagesDefaultIsl then
  324. LanguagesList.AddCheckBox(SpaceLanguageName(PathChangeExt(FLanguages[I], '')), '', 0, False, True, False, True, TObject(I))
  325. else
  326. LanguagesList.AddCheckBox(LanguagesDefaultIslDescription, '', 0, True, True, False, True, TObject(I));
  327. end;
  328. { Compiler }
  329. OutputBaseFileNameEdit.Text := 'mysetup';
  330. EncryptionCheck.Checked := True;
  331. EncryptionCheck.Enabled := False;
  332. { ISPP }
  333. ISPPLabel.Caption := FixLabel(SWizardISPPLabel);
  334. ISPPCheck.Caption := SWizardISPPCheck;
  335. ISPPCheck.Checked := ISPPInstalled;
  336. CurPage := Low(TWizardPage);
  337. CurPageChanged;
  338. end;
  339. procedure TWizardForm.FormShow(Sender: TObject);
  340. begin
  341. Caption := FWizardName;
  342. WelcomeLabel1.Caption := FixLabel(WelcomeLabel1.Caption);
  343. FinishedLabel.Caption := FixLabel(FinishedLabel.Caption);
  344. end;
  345. procedure TWizardForm.FormCloseQuery(Sender: TObject;
  346. var CanClose: Boolean);
  347. begin
  348. if ModalResult = mrCancel then
  349. CanClose := MsgBox(FixLabel(SWizardCancelMessage), FWizardName, mbConfirmation, MB_YESNO) = idYes;
  350. end;
  351. procedure TWizardForm.FormDestroy(Sender: TObject);
  352. begin
  353. FLanguages.Free;
  354. FRegistryHelper.Free;
  355. FFilesHelper.Free;
  356. end;
  357. { --- }
  358. procedure TWizardForm.CurPageChanged;
  359. { Call this whenever the current page is changed }
  360. begin
  361. OuterNotebook.ActivePage := OuterNotebook.Pages[NotebookPages[CurPage, 0]];
  362. if NotebookPages[CurPage, 1] <> -1 then
  363. InnerNotebook.ActivePage := InnerNotebook.Pages[NotebookPages[CurPage, 1]];
  364. { Set button visibility and captions }
  365. BackButton.Visible := not (CurPage = wpWelcome);
  366. if CurPage = wpFinished then
  367. NextButton.Caption := SWizardFinishButton
  368. else
  369. NextButton.Caption := SWizardNextButton;
  370. RequiredLabel1.Visible := RequiredLabelVisibles[CurPage];
  371. RequiredLabel2.Visible := RequiredLabel1.Visible;
  372. { Set the Caption to match the current page's title }
  373. PageNameLabel.Caption := PageCaptions[CurPage];
  374. PageDescriptionLabel.Caption := PageDescriptions[CurPage];
  375. { Adjust focus }
  376. case CurPage of
  377. wpAppInfo: ActiveControl := AppNameEdit;
  378. wpAppDir:
  379. begin
  380. if AppRootDirComboBox.Enabled then
  381. ActiveControl := AppRootDirComboBox
  382. else
  383. ActiveControl := NotCreateAppDirCheck;
  384. end;
  385. wpAppFiles:
  386. begin
  387. if AppExeEdit.Enabled then
  388. ActiveControl := AppExeEdit
  389. else
  390. ActiveControl := AppFilesListBox;
  391. end;
  392. wpAppAssoc: ActiveControl := CreateAssocCheck;
  393. wpAppIcons:
  394. begin
  395. if UseAutoProgramsCheck.Enabled then
  396. ActiveControl := UseAutoProgramsCheck
  397. else
  398. ActiveControl := AppGroupNameEdit;
  399. end;
  400. wpAppDocs: ActiveControl := AppLicenseFileEdit;
  401. wpPrivilegesRequired:
  402. begin
  403. if PrivilegesRequiredAdminRadioButton.Checked then
  404. ActiveControl := PrivilegesRequiredAdminRadioButton
  405. else
  406. ActiveControl := PrivilegesRequiredLowestRadioButton;
  407. end;
  408. wpAppRegistry: ActiveControl := AppRegistryFileEdit;
  409. wpLanguages: ActiveControl := LanguagesList;
  410. wpCompiler: ActiveControl := OutputDirEdit;
  411. wpISPP: ActiveControl := ISPPCheck;
  412. end;
  413. end;
  414. function TWizardForm.SkipCurPage: Boolean;
  415. begin
  416. if ((CurPage = wpAppAssoc) and not CreateAssocCheck.Enabled) or
  417. ((CurPage = wpAppIcons) and NotCreateAppDirCheck.Checked) or
  418. ((CurPage = wpLanguages) and not (FLanguages.Count > 1)) or
  419. ((CurPage = wpISPP) and not ISPPInstalled) or
  420. (not (CurPage in [wpWelcome, wpFinished]) and EmptyCheck.Checked) then
  421. Result := True
  422. else
  423. Result := False;
  424. end;
  425. procedure TWizardForm.NextButtonClick(Sender: TObject);
  426. function CheckAppInfoPage: Boolean;
  427. begin
  428. Result := False;
  429. if AppNameEdit.Text = '' then begin
  430. MsgBox(SWizardAppNameError, '', mbError, MB_OK);
  431. ActiveControl := AppNameEdit;
  432. end else if AppVersionEdit.Text = '' then begin
  433. MsgBox(SWizardAppVersionError, '', mbError, MB_OK);
  434. ActiveControl := AppVersionEdit;
  435. end else
  436. Result := True;
  437. end;
  438. function CheckAppDirPage: Boolean;
  439. begin
  440. Result := False;
  441. if not NotCreateAppDirCheck.Checked and
  442. (AppRootDirComboBox.ItemIndex = AppRootDirComboBox.Items.Count-1) and
  443. (AppRootDirEdit.Text = '') then begin
  444. MsgBox(SWizardAppRootDirError, '', mbError, MB_OK);
  445. ActiveControl := AppRootDirEdit;
  446. end else if not NotCreateAppDirCheck.Checked and (AppDirNameEdit.Text = '') then begin
  447. MsgBox(SWizardAppDirNameError, '', mbError, MB_OK);
  448. ActiveControl := AppDirNameEdit;
  449. end else
  450. Result := True;
  451. end;
  452. function CheckAppFilesPage: Boolean;
  453. begin
  454. Result := False;
  455. if AppExeEdit.Enabled and (AppExeEdit.Text = '') then begin
  456. MsgBox(SWizardAppExeError, '', mbError, MB_OK);
  457. ActiveControl := AppExeEdit;
  458. end else
  459. Result := True;
  460. end;
  461. function CheckAppIconsPage: Boolean;
  462. begin
  463. Result := False;
  464. if AppGroupNameEdit.Text = '' then begin
  465. MsgBox(SWizardAppGroupNameError, '', mbError, MB_OK);
  466. ActiveControl := AppGroupNameEdit;
  467. end else
  468. Result := True;
  469. end;
  470. function CheckLanguagesPage: Boolean;
  471. var
  472. I: Integer;
  473. begin
  474. Result := False;
  475. for I := 0 to LanguagesList.Items.Count-1 do begin
  476. if LanguagesList.Checked[I] then begin
  477. Result := True;
  478. Exit;
  479. end;
  480. end;
  481. MsgBox(SWizardLanguagesSelError, '', mbError, MB_OK);
  482. ActiveControl := LanguagesList;
  483. end;
  484. begin
  485. case CurPage of
  486. wpAppInfo: if not CheckAppInfoPage then Exit;
  487. wpAppDir: if not CheckAppDirPage then Exit;
  488. wpAppFiles: if not CheckAppFilesPage then Exit;
  489. wpAppIcons: if not CheckAppIconsPage then Exit;
  490. wpLanguages: if not CheckLanguagesPage then Exit;
  491. end;
  492. repeat
  493. if CurPage = wpAppAssoc then begin
  494. if (AppAssocExtEdit.Text <> '') and (AppAssocExtEdit.Text[1] <> '.') then
  495. AppAssocExtEdit.Text := '.' + AppAssocExtEdit.Text;
  496. end else if CurPage = wpPrivilegesRequired then begin
  497. if not PrivilegesRequiredOverridesAllowedCommandLineCheckbox.Checked then begin
  498. if PrivilegesRequiredAdminRadioButton.Checked then
  499. FRegistryHelper.PrivilegesRequired := prAdmin
  500. else
  501. FRegistryHelper.PrivilegesRequired := prLowest
  502. end else
  503. FRegistryHelper.PrivilegesRequired := prDynamic;
  504. end else if CurPage = wpFinished then begin
  505. GenerateScript;
  506. ModalResult := mrOk;
  507. Exit;
  508. end;
  509. Inc(CurPage);
  510. { Even if we're skipping a page, we should still update it }
  511. case CurPage of
  512. wpAppDir: if AppDirNameEdit.Text = '' then AppDirNameEdit.Text := AppNameEdit.Text;
  513. wpAppAssoc: if AppAssocNameEdit.Text = '' then AppAssocNameEdit.Text := AppNameEdit.Text + ' File';
  514. wpAppIcons: if AppGroupNameEdit.Text = '' then AppGroupNameEdit.Text := AppNameEdit.Text;
  515. end;
  516. until not SkipCurPage;
  517. CurPageChanged;
  518. end;
  519. procedure TWizardForm.BackButtonClick(Sender: TObject);
  520. begin
  521. if CurPage = Low(TWizardPage) then Exit;
  522. { Go to the previous page }
  523. Dec(CurPage);
  524. while SkipCurPage do
  525. Dec(CurPage);
  526. CurPageChanged;
  527. end;
  528. {---}
  529. procedure TWizardForm.UpdateAppExeControls;
  530. var
  531. Enabled: Boolean;
  532. begin
  533. Enabled := not NotCreateAppDirCheck.Checked;
  534. NoAppExeCheck.Enabled := Enabled;
  535. Enabled := Enabled and not NoAppExeCheck.Checked;
  536. AppExeLabel.Enabled := Enabled;
  537. AppExeEdit.Enabled := Enabled;
  538. AppExeEdit.Color := EnabledColors[Enabled];
  539. AppExeButton.Enabled := Enabled;
  540. AppExeRunCheck.Enabled := Enabled;
  541. AppExeIconsLabel.Enabled := Enabled;
  542. DesktopIconCheck.Enabled := Enabled;
  543. if Enabled then
  544. AppExeLabel.Font.Style := AppExeLabel.Font.Style + [fsBold]
  545. else
  546. AppExeLabel.Font.Style := AppExeLabel.Font.Style - [fsBold];
  547. end;
  548. procedure TWizardForm.UpdateAppAssocControls;
  549. var
  550. Enabled: Boolean;
  551. begin
  552. Enabled := not NoAppExeCheck.Checked;
  553. CreateAssocCheck.Enabled := Enabled;
  554. Enabled := Enabled and CreateAssocCheck.Checked;
  555. AppAssocNameLabel.Enabled := Enabled;
  556. AppAssocNameEdit.Enabled := Enabled;
  557. AppAssocExtLabel.Enabled := Enabled;
  558. AppAssocExtEdit.Enabled := Enabled;
  559. if Enabled then begin
  560. AppAssocNameLabel.Font.Style := AppAssocNameLabel.Font.Style + [fsBold];
  561. AppAssocExtLabel.Font.Style := AppAssocExtLabel.Font.Style + [fsBold];
  562. end else begin
  563. AppAssocNameLabel.Font.Style := AppAssocNameLabel.Font.Style - [fsBold];
  564. AppAssocExtLabel.Font.Style := AppAssocExtLabel.Font.Style - [fsBold];
  565. end;
  566. end;
  567. procedure TWizardForm.UpdateAppIconsControls;
  568. var
  569. Enabled: Boolean;
  570. begin
  571. UseAutoProgramsCheck.Enabled := NoAppExeCheck.Enabled and not NoAppExeCheck.Checked;
  572. Enabled := not (UseAutoProgramsCheck.Enabled and UseAutoProgramsCheck.Checked);
  573. AppGroupNameLabel.Enabled := Enabled;
  574. AppGroupNameEdit.Enabled := Enabled;
  575. AppGroupNameEdit.Color := EnabledColors[Enabled];
  576. NotDisableProgramGroupPageCheck.Enabled := Enabled;
  577. AllowNoIconsCheck.Enabled := Enabled and NotDisableProgramGroupPageCheck.Checked;
  578. CreateURLIconCheck.Enabled := Enabled and (AppURLEdit.Text <> '');
  579. CreateUninstallIconCheck.Enabled := Enabled;
  580. if Enabled then
  581. AppGroupNameLabel.Font.Style := AppGroupNameLabel.Font.Style + [fsBold]
  582. else
  583. AppGroupNameLabel.Font.Style := AppGroupNameLabel.Font.Style - [fsBold];
  584. end;
  585. {---}
  586. procedure TWizardForm.AppRootDirComboBoxChange(Sender: TObject);
  587. begin
  588. if AppRootDirComboBox.ItemIndex = AppRootDirComboBox.Items.Count-1 then begin
  589. AppRootDirEdit.Enabled := True;
  590. AppRootDirEdit.Color := clWindow;
  591. ActiveControl := AppRootDirEdit;
  592. end else begin
  593. AppRootDirEdit.Enabled := False;
  594. AppRootDirEdit.Color := clBtnFace;
  595. end;
  596. end;
  597. procedure TWizardForm.NotCreateAppDirCheckClick(Sender: TObject);
  598. var
  599. Enabled: Boolean;
  600. begin
  601. Enabled := not NotCreateAppDirCheck.Checked;
  602. { AppDir }
  603. AppRootDirLabel.Enabled := Enabled;
  604. AppRootDirComboBox.Enabled := Enabled;
  605. AppRootDirComboBox.Color := EnabledColors[Enabled];
  606. AppRootDirEdit.Enabled := Enabled and (AppRootDirComboBox.ItemIndex = AppRootDirComboBox.Items.Count-1);
  607. AppRootDirEdit.Color := EnabledColors[AppRootDirEdit.Enabled];
  608. AppDirNameLabel.Enabled := Enabled;
  609. AppDirNameEdit.Enabled := Enabled;
  610. AppDirNameEdit.Color := EnabledColors[Enabled];
  611. NotDisableDirPageCheck.Enabled := Enabled;
  612. if Enabled then begin
  613. AppRootDirLabel.Font.Style := AppRootDirLabel.Font.Style + [fsBold];
  614. AppDirNameLabel.Font.Style := AppRootDirLabel.Font.Style + [fsBold];
  615. end else begin
  616. AppRootDirLabel.Font.Style := AppRootDirLabel.Font.Style - [fsBold];
  617. AppDirNameLabel.Font.Style := AppRootDirLabel.Font.Style - [fsBold];
  618. end;
  619. { AppFiles }
  620. UpdateAppExeControls;
  621. end;
  622. procedure TWizardForm.AppExeButtonClick(Sender: TObject);
  623. var
  624. FileName: String;
  625. begin
  626. FileName := AppExeEdit.Text;
  627. if NewGetOpenFileName('', FileName, PathExtractPath(FileName), SWizardAppExeFilter, SWizardAppExeDefaultExt, Handle) then
  628. AppExeEdit.Text := FileName;
  629. end;
  630. procedure TWizardForm.NoAppExeCheckClick(Sender: TObject);
  631. begin
  632. UpdateAppExeControls;
  633. UpdateAppAssocControls;
  634. UpdateAppIconsControls;
  635. end;
  636. procedure TWizardForm.CreateAssocCheckClick(Sender: TObject);
  637. begin
  638. UpdateAppAssocControls;
  639. end;
  640. procedure TWizardForm.UseAutoProgramsCheckClick(Sender: TObject);
  641. begin
  642. UpdateAppIconsControls;
  643. end;
  644. procedure TWizardForm.NotDisableProgramGroupPageCheckClick(
  645. Sender: TObject);
  646. begin
  647. UpdateAppIconsControls;
  648. end;
  649. procedure TWizardForm.FileButtonClick(Sender: TObject);
  650. var
  651. Edit: TEdit;
  652. Filter, DefaultExt, FileName: String;
  653. begin
  654. if Sender = AppLicenseFileButton then
  655. Edit := AppLicenseFileEdit
  656. else if Sender = AppInfoBeforeFileButton then
  657. Edit := AppInfoBeforeFileEdit
  658. else if Sender = AppInfoAfterFileButton then
  659. Edit := AppInfoAfterFileEdit
  660. else
  661. Edit := SetupIconFileEdit;
  662. if Sender <> SetupIconFileButton then begin
  663. Filter := SWizardAppDocsFilter;
  664. DefaultExt := SWizardAppDocsDefaultExt;
  665. end else begin
  666. Filter := SWizardCompilerSetupIconFileFilter;
  667. DefaultExt := SWizardCompilerSetupIconFileDefaultExt;
  668. end;
  669. FileName := Edit.Text;
  670. if NewGetOpenFileName('', FileName, PathExtractPath(FileName), Filter, DefaultExt, Handle) then
  671. Edit.Text := FileName;
  672. end;
  673. procedure TWizardForm.OutputDirButtonClick(Sender: TObject);
  674. var
  675. Path: String;
  676. begin
  677. Path := OutputDirEdit.Text;
  678. if PathDrivePartLength(Path) = 0 then
  679. Path := ''; { don't pass in a relative path to BrowseForFolder }
  680. if BrowseForFolder(SWizardCompilerOutputDir, Path, Handle, True) then
  681. OutputDirEdit.Text := Path;
  682. end;
  683. procedure TWizardForm.PasswordEditChange(Sender: TObject);
  684. begin
  685. EncryptionCheck.Enabled := PasswordEdit.Text <> '';
  686. end;
  687. procedure TWizardForm.AllLanguagesButtonClick(Sender: TObject);
  688. var
  689. I: Integer;
  690. begin
  691. for I := 0 to LanguagesList.Items.Count-1 do
  692. LanguagesList.Checked[I] := True;
  693. end;
  694. procedure TWizardForm.NoLanguagesButtonClick(Sender: TObject);
  695. var
  696. I: Integer;
  697. begin
  698. for I := 0 to LanguagesList.Items.Count-1 do
  699. LanguagesList.Checked[I] := False;
  700. end;
  701. procedure TWizardForm.PrivilegesRequiredOverridesAllowedDialogCheckboxClick(
  702. Sender: TObject);
  703. begin
  704. PrivilegesRequiredOverridesAllowedCommandLineCheckbox.Enabled := not PrivilegesRequiredOverridesAllowedDialogCheckbox.Checked;
  705. if PrivilegesRequiredOverridesAllowedDialogCheckbox.Checked then
  706. PrivilegesRequiredOverridesAllowedCommandLineCheckbox.Checked := True;
  707. end;
  708. { --- }
  709. procedure TWizardForm.GenerateScript;
  710. function Is64BitPEImage(const Filename: String): Boolean;
  711. { Returns True if the specified file is a non-32-bit PE image, False
  712. otherwise. }
  713. var
  714. F: TFile;
  715. DosHeader: packed record
  716. Sig: array[0..1] of AnsiChar;
  717. Other: array[0..57] of Byte;
  718. PEHeaderOffset: LongWord;
  719. end;
  720. PESigAndHeader: packed record
  721. Sig: DWORD;
  722. Header: TImageFileHeader;
  723. OptHeaderMagic: Word;
  724. end;
  725. begin
  726. Result := False;
  727. F := TFile.Create(Filename, fdOpenExisting, faRead, fsRead);
  728. try
  729. if F.Read(DosHeader, SizeOf(DosHeader)) = SizeOf(DosHeader) then begin
  730. if (DosHeader.Sig[0] = 'M') and (DosHeader.Sig[1] = 'Z') and
  731. (DosHeader.PEHeaderOffset <> 0) then begin
  732. F.Seek(DosHeader.PEHeaderOffset);
  733. if F.Read(PESigAndHeader, SizeOf(PESigAndHeader)) = SizeOf(PESigAndHeader) then begin
  734. if (PESigAndHeader.Sig = IMAGE_NT_SIGNATURE) and
  735. (PESigAndHeader.OptHeaderMagic <> IMAGE_NT_OPTIONAL_HDR32_MAGIC) then
  736. Result := True;
  737. end;
  738. end;
  739. end;
  740. finally
  741. F.Free;
  742. end;
  743. end;
  744. var
  745. Script, ISPP, Setup, Languages, Tasks, Files, Registry, INI, Icons, Run, UninstallDelete: String;
  746. I: Integer;
  747. AppExeName, AppName, AppAmpEscapedName, AppAssocKey, LanguageName, LanguageMessagesFile: String;
  748. begin
  749. Script := '';
  750. AppExeName := PathExtractName(AppExeEdit.Text);
  751. AppName := AppNameEdit.Text;
  752. AppAmpEscapedName := EscapeAmpersands(AppName);
  753. if ISPPCheck.Checked then begin
  754. { Setup ISPP usage. Change the edits to reflect ISPP usage. A bit ugly but for now it works. }
  755. ISPP := '#define MyAppName "' + AppNameEdit.Text + '"' + SNewLine +
  756. '#define MyAppVersion "' + AppVersionEdit.Text + '"' + SNewLine;
  757. if AppDirNameEdit.Text = AppNameEdit.Text then
  758. AppDirNameEdit.Text := '{#MyAppName}';
  759. if AppGroupNameEdit.Text = AppNameEdit.Text then
  760. AppGroupNameEdit.Text := '{#MyAppName}';
  761. AppNameEdit.Text := '{#MyAppName}';
  762. AppAmpEscapedName := '{#StringChange(MyAppName, ''&'', ''&&'')}';
  763. AppVersionEdit.Text := '{#MyAppVersion}';
  764. if AppPublisherEdit.Text <> '' then begin
  765. ISPP := ISPP + '#define MyAppPublisher "' + AppPublisherEdit.Text + '"' + SNewLine;
  766. AppPublisherEdit.Text := '{#MyAppPublisher}';
  767. end;
  768. if AppURLEdit.Text <> '' then begin
  769. ISPP := ISPP + '#define MyAppURL "' + AppURLEdit.Text + '"' + SNewLine;
  770. AppURLEdit.Text := '{#MyAppURL}';
  771. end;
  772. { Special ones }
  773. if not NoAppExeCheck.Checked then begin
  774. ISPP := ISPP + '#define MyAppExeName "' + AppExeName + '"' + SNewLine;
  775. AppExeName := '{#MyAppExeName}';
  776. end;
  777. if CreateAssocCheck.Enabled and CreateAssocCheck.Checked then begin
  778. if Pos(AppName, AppAssocNameEdit.Text) = 1 then
  779. ISPP := ISPP + '#define MyAppAssocName MyAppName + "' + Copy(AppAssocNameEdit.Text, Length(AppName)+1, MaxInt) + '"' + SNewLine
  780. else
  781. ISPP := ISPP + '#define MyAppAssocName "' + AppAssocNameEdit.Text + '"' + SNewLine;
  782. AppAssocNameEdit.Text := '{#MyAppAssocName}';
  783. ISPP := ISPP + '#define MyAppAssocExt "' + AppAssocExtEdit.Text + '"' + SNewLine;
  784. AppAssocExtEdit.Text := '{#MyAppAssocExt}';
  785. ISPP := ISPP + '#define MyAppAssocKey StringChange(MyAppAssocName, " ", "") + MyAppAssocExt' + SNewLine;
  786. AppAssocKey := '{#MyAppAssocKey}';
  787. end;
  788. end else begin
  789. ISPP := '';
  790. AppAssocKey := StringReplace(AppAssocNameEdit.Text, ' ', '', [rfReplaceAll]) + AppAssocExtEdit.Text;
  791. end;
  792. Setup := '[Setup]' + SNewLine;
  793. Languages := '[Languages]' + SNewLine;
  794. Tasks := '[Tasks]' + SNewLine;
  795. Files := '[Files]' + SNewLine;
  796. Registry := '[Registry]' + SNewLine;
  797. INI := '[INI]' + SNewLine;
  798. Icons := '[Icons]' + SNewLine;
  799. Run := '[Run]' + SNewLine;
  800. UninstallDelete := '[UninstallDelete]' + SNewLine;
  801. if not EmptyCheck.Checked then begin
  802. Setup := Setup + (
  803. '; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.' + SNewLine +
  804. '; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)' + SNewLine);
  805. Setup := Setup + 'AppId={' + GenerateGuid + SNewLine;
  806. { AppInfo }
  807. Setup := Setup + 'AppName=' + AppNameEdit.Text + SNewLine;
  808. Setup := Setup + 'AppVersion=' + AppVersionEdit.Text + SNewLine;
  809. Setup := Setup + ';AppVerName=' + AppNameEdit.Text + ' ' + AppVersionEdit.Text + SNewLine;
  810. if AppPublisherEdit.Text <> '' then
  811. Setup := Setup + 'AppPublisher=' + AppPublisherEdit.Text + SNewLine;
  812. if AppURLEdit.Text <> '' then begin
  813. Setup := Setup + 'AppPublisherURL=' + AppURLEdit.Text + SNewLine;
  814. Setup := Setup + 'AppSupportURL=' + AppURLEdit.Text + SNewLine;
  815. Setup := Setup + 'AppUpdatesURL=' + AppURLEdit.Text + SNewLine;
  816. end;
  817. { AppDir }
  818. if not NotCreateAppDirCheck.Checked then begin
  819. if AppRootDirComboBox.ItemIndex = AppRootDirComboBox.Items.Count-1 then
  820. Setup := Setup + 'DefaultDirName=' + AddBackslash(AppRootDirEdit.Text) + AppDirNameEdit.Text + SNewLine
  821. else
  822. Setup := Setup + 'DefaultDirName=' + AddBackslash(AppRootDirs[AppRootDirComboBox.ItemIndex].Constant) + AppDirNameEdit.Text + SNewLine;
  823. if not NotDisableDirPageCheck.Checked then
  824. Setup := Setup + 'DisableDirPage=yes' + SNewLine;
  825. end else begin
  826. Setup := Setup + 'CreateAppDir=no' + SNewLine;
  827. end;
  828. { AppFiles }
  829. if not NotCreateAppDirCheck.Checked and not NoAppExeCheck.Checked then begin
  830. Files := Files + 'Source: "' + PathExtractPath(AppExeEdit.Text) + AppExeName + '"; DestDir: "{app}"; Flags: ignoreversion' + SNewLine;
  831. var AppExeIsReallyExe := SameText(PathExtractExt(AppExeEdit.Text), '.exe');
  832. if AppExeRunCheck.Checked then begin
  833. if AppExeIsReallyExe then
  834. Run := Run + 'Filename: "{app}\' + AppExeName + '"; Description: "{cm:LaunchProgram,' + AppAmpEscapedName + '}"; Flags: nowait postinstall skipifsilent' + SNewLine
  835. else
  836. Run := Run + 'Filename: "{app}\' + AppExeName + '"; Description: "{cm:LaunchProgram,' + AppAmpEscapedName + '}"; Flags: shellexec postinstall skipifsilent' + SNewLine;
  837. end;
  838. if AppExeIsReallyExe then
  839. Setup := Setup + 'UninstallDisplayIcon={app}\' + AppExeName + SNewLine;
  840. if Is64BitPEImage(AppExeEdit.Text) then begin
  841. Setup := Setup + '; "ArchitecturesAllowed=x64compatible" specifies that Setup cannot run' + SNewLine;
  842. Setup := Setup + '; on anything but x64 and Windows 11 on Arm.' + SNewLine;
  843. Setup := Setup + 'ArchitecturesAllowed=x64compatible' + SNewLine;
  844. Setup := Setup + '; "ArchitecturesInstallIn64BitMode=x64compatible" requests that the' + SNewLine;
  845. Setup := Setup + '; install be done in "64-bit mode" on x64 or Windows 11 on Arm,' + SNewLine;
  846. Setup := Setup + '; meaning it should use the native 64-bit Program Files directory and' + SNewLine;
  847. Setup := Setup + '; the 64-bit view of the registry.' + SNewLine;
  848. Setup := Setup + 'ArchitecturesInstallIn64BitMode=x64compatible' + SNewLine;
  849. end;
  850. end;
  851. { AppAssocation }
  852. if CreateAssocCheck.Enabled and CreateAssocCheck.Checked then begin
  853. Setup := Setup + 'ChangesAssociations=yes' + SNewLine;
  854. Registry := Registry + 'Root: HKA; Subkey: "Software\Classes\' + AppAssocExtEdit.Text + '\OpenWithProgids"; ValueType: string; ValueName: "' + AppAssocKey + '"; ValueData: ""; Flags: uninsdeletevalue' + SNewLine;
  855. Registry := Registry + 'Root: HKA; Subkey: "Software\Classes\' + AppAssocKey + '"; ValueType: string; ValueName: ""; ValueData: "' + AppAssocNameEdit.Text + '"; Flags: uninsdeletekey' + SNewLine;
  856. Registry := Registry + 'Root: HKA; Subkey: "Software\Classes\' + AppAssocKey + '\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\' + AppExeName + ',0"' + SNewLine;
  857. Registry := Registry + 'Root: HKA; Subkey: "Software\Classes\' + AppAssocKey + '\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\' + AppExeName + '"" ""%1"""' + SNewLine;
  858. end;
  859. FFilesHelper.AddScript(Files);
  860. { AppGroup }
  861. if not NotCreateAppDirCheck.Checked then begin
  862. if UseAutoProgramsCheck.Enabled and UseAutoProgramsCheck.Checked then begin
  863. Setup := Setup + 'DisableProgramGroupPage=yes' + SNewLine;
  864. Icons := Icons + 'Name: "{autoprograms}\' + AppNameEdit.Text + '"; Filename: "{app}\' + AppExeName + '"' + SNewLine;
  865. end else begin
  866. Setup := Setup + 'DefaultGroupName=' + AppGroupNameEdit.Text + SNewLine;
  867. if not NoAppExeCheck.Checked then
  868. Icons := Icons + 'Name: "{group}\' + AppNameEdit.Text + '"; Filename: "{app}\' + AppExeName + '"' + SNewLine;
  869. if not NotDisableProgramGroupPageCheck.Checked then
  870. Setup := Setup + 'DisableProgramGroupPage=yes' + SNewLine;
  871. if AllowNoIconsCheck.Checked and NotDisableProgramGroupPageCheck.Checked then
  872. Setup := Setup + 'AllowNoIcons=yes' + SNewLine;
  873. if CreateURLIconCheck.Enabled and CreateURLIconCheck.Checked then
  874. Icons := Icons + 'Name: "{group}\{cm:ProgramOnTheWeb,' + AppNameEdit.Text + '}"; Filename: "' + AppURLEdit.Text + '"' + SNewLine;
  875. if CreateUninstallIconCheck.Checked then
  876. Icons := Icons + 'Name: "{group}\{cm:UninstallProgram,' + AppNameEdit.Text + '}"; Filename: "{uninstallexe}"' + SNewLine;
  877. end;
  878. if DesktopIconCheck.Enabled and DesktopIconCheck.Checked then begin
  879. Tasks := Tasks + 'Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked' + SNewLine;
  880. Icons := Icons + 'Name: "{autodesktop}\' + AppNameEdit.Text + '"; Filename: "{app}\' + AppExeName + '"; Tasks: desktopicon' + SNewLine;
  881. end;
  882. end;
  883. { AppDocs }
  884. if AppLicenseFileEdit.Text <> '' then
  885. Setup := Setup + 'LicenseFile=' + AppLicenseFileEdit.Text + SNewLine;
  886. if AppInfoBeforeFileEdit.Text <> '' then
  887. Setup := Setup + 'InfoBeforeFile=' + AppInfoBeforeFileEdit.Text + SNewLine;
  888. if AppInfoAfterFileEdit.Text <> '' then
  889. Setup := Setup + 'InfoAfterFile=' + AppInfoAfterFileEdit.Text + SNewLine;
  890. { PrivilegesRequired }
  891. if PrivilegesRequiredAdminRadioButton.Checked then
  892. Setup := Setup + '; Uncomment the following line to run in non administrative install mode (install for current user only).' + SNewLine + ';'
  893. else
  894. Setup := Setup + '; Remove the following line to run in administrative install mode (install for all users).' + SNewLine;
  895. Setup := Setup + 'PrivilegesRequired=lowest' + SNewLine; { Note how previous made sure this is outputted as comment if needed. }
  896. if PrivilegesRequiredOverridesAllowedDialogCheckbox.Checked then
  897. Setup := Setup + 'PrivilegesRequiredOverridesAllowed=dialog' + SNewLine
  898. else if PrivilegesRequiredOverridesAllowedCommandLineCheckbox.Checked then
  899. Setup := Setup + 'PrivilegesRequiredOverridesAllowed=commandline' + SNewLine;
  900. { AppRegistry }
  901. FRegistryHelper.AddScript(Registry, False);
  902. { Languages }
  903. if FLanguages.Count > 1 then begin
  904. for I := 0 to LanguagesList.Items.Count-1 do begin
  905. if LanguagesList.Checked[I] then begin
  906. LanguageMessagesFile := FLanguages[Integer(LanguagesList.ItemObject[I])];
  907. if LanguageMessagesFile <> LanguagesDefaultIsl then begin
  908. LanguageName := LanguagesList.Items[I];
  909. LanguageMessagesFile := 'Languages\' + LanguageMessagesFile;
  910. end else
  911. LanguageName := LanguagesDefaultIslDescription;
  912. StringChange(LanguageName, ' ', '');
  913. LanguageName := LowerCase(LanguageName);
  914. Languages := Languages + 'Name: "' + LanguageName + '"; MessagesFile: "compiler:' + LanguageMessagesFile + '"' + SNewLine;
  915. end;
  916. end;
  917. end;
  918. { Compiler }
  919. if OutputDirEdit.Text <> '' then
  920. Setup := Setup + 'OutputDir=' + OutputDirEdit.Text + SNewLine;
  921. if OutputBaseFileNameEdit.Text <> '' then
  922. Setup := Setup + 'OutputBaseFilename=' + OutputBaseFileNameEdit.Text + SNewLine;
  923. if SetupIconFileEdit.Text <> '' then
  924. Setup := Setup + 'SetupIconFile=' + SetupIconFileEdit.Text + SNewLine;
  925. if PasswordEdit.Text <> '' then begin
  926. Setup := Setup + 'Password=' + PasswordEdit.Text + SNewLine;
  927. if EncryptionCheck.Checked then
  928. Setup := Setup + 'Encryption=yes' + SNewLine;
  929. end;
  930. { Other }
  931. Setup := Setup + 'SolidCompression=yes' + SNewLine;
  932. Setup := Setup + 'WizardStyle=modern' + SNewLine;
  933. { Build script }
  934. if ISPP <> '' then
  935. Script := Script + ISPP + SNewLine;
  936. Script := Script + Setup + SNewLine;
  937. if Length(Languages) > Length('[Languages]')+2 then
  938. Script := Script + Languages + SNewLine;
  939. if Length(Tasks) > Length('[Tasks]')+2 then
  940. Script := Script + Tasks + SNewLine;
  941. if Length(Files) > Length('[Files]')+2 then
  942. Script := Script + Files +
  943. '; NOTE: Don''t use "Flags: ignoreversion" on any shared system files' +
  944. SNewLine2;
  945. if Length(Registry) > Length('[Registry]')+2 then
  946. Script := Script + Registry + SNewLine;
  947. if Length(INI) > Length('[INI]')+2 then
  948. Script := Script + INI + SNewLine;
  949. if Length(Icons) > Length('[Icons]')+2 then
  950. Script := Script + Icons + SNewLine;
  951. if Length(Run) > Length('[Run]')+2 then
  952. Script := Script + Run + SNewLine;
  953. if Length(UninstallDelete) > Length('[UninstallDelete]')+2 then
  954. Script := Script + UninstallDelete + SNewLine;
  955. FResult := wrComplete;
  956. end else begin
  957. Script := Script + Setup;
  958. FResult := wrEmpty;
  959. end;
  960. FResultScript := FixLabel(SWizardScriptHeader) + SNewLine2 + Script;
  961. end;
  962. { --- }
  963. end.