CompWizard.pas 41 KB

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