IDE.Wizard.WizardForm.pas 40 KB

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