IDE.Wizard.WizardForm.pas 40 KB

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