Customized Page instance in ISTOOL

xiaoxiao2021-03-06  45

; -. CodeDlg.iss - ;; This script shows how to insert custom wizard pages into Setup and how to handle; navigation between those pages if multiple custom pages are inserted after each; other Furthermore it shows how to 'communicate' between .................... ..

[Setup] AppName = my programappvername = my program version 1.5DEFAULTDIRNAME = {PF} / my programdisableprogramgrouppage = yesuninstallDisplayicon = {app} /myprog.exe

[Files] Source: myprog.exe; destdir: {app} Source: myprog.hlp; deAdmeter: {app} Source: readme.txt; deAdMe.txt; deAddir: {app}; Flags: isReadme

[Registry] Root: HKCU; Subkey: Software / My Company; Flags: uninsdeletekeyifemptyRoot: HKCU; Subkey: Software / My Company / My Program; Flags: uninsdeletekeyRoot: HKCU; Subkey: Software / My Company / My Program / Settings; ValueType: string; ValueName: Name; ValueData: {code: GetUser | Name} Root: HKCU; Subkey: Software / My Company / My Program / Settings; ValueType: string; ValueName: Company; ValueData: {code: GetUser | Company} Root: HKCU; Subkey: Software / My Company / My Program / Settings; ValueType: String; Valuename: DATADIR; VALUEDATA: {Code: getDataDir}; etc.

[DIRS] Name: {Code: getDataDir}; Flags: UninsneverunStall

[Code] VAR UserPromPTS, Uservalues: tarrayofstring; usageprompts, usageValues: tarness; data;

Function initializsetup (): boolean; begin {set promots used on custom wizard pages} setArraylength (userPromPTS, 2); userPrompts [0]: = 'name:'; userprompts [1]: = 'Company:';

SetArrayLength (UsagePrompts, 3) UsagePrompts [0]: = 'Light mode (no ads, limited functionality)'; UsagePrompts [1]: = 'Sponsored mode (with ads, full functionality)'; UsagePrompts [2]: = 'Paid mode (no ads, full functionality) '; {Set default values} SetArrayLength (UserValues, 2); RegQueryStringValue (HKLM,' Software / Microsoft / Windows / CurrentVersion ',' RegisteredOwner ', UserValues ​​[0]); RegQueryStringValue (HKLM, 'Software / Microsoft / Windows / CurrentVersion', 'RegisteredOrganization', UserValues ​​[1]); if (UserValues ​​[0] = '') and (UserValues ​​[1] = '') then begin RegQueryStringValue (HKCU, 'Software / Microsoft / MS Setup (ACME) / User Info ',' DEFNAME ', UserValues ​​[0]); RegQueryStringValue (HKCU,' Software / Microsoft / MS Setup (ACME) / User Info ',' Defcompany ', UserValues ​​[1]); END;

SetArrayLength (usagevalues, 3) usagevalues ​​[1]: = '1';

{Try to Find the settings That WERE Stored Last Time (Also See Below).} Uservalues ​​[0]: = getPreviousData ('name', uservalues ​​[0]); uservalues ​​[1]: = getPreviousData ('Company', Uservalues ​​" 1]); USAGEVALUES [0]: = getpreviousdata ('Light Mode', USAGEVALUES [0]); usagevalues ​​[1]: = getPreviousData ('sponsored mode', usagevalues ​​[1]); usagevalues ​​[2]: = getPreviousData 'PAID MODE', USAGEVALUES [2]); DATADIR: = GetPreviousData ('DATADIR', '');

{Let setup run} result: = true;

procedure RegisterPreviousData (PreviousDataKey: Integer); begin {Store the settings so we can restore them next time} SetPreviousData (PreviousDataKey, 'Name', UserValues ​​[0]); SetPreviousData (PreviousDataKey, 'Company', UserValues ​​[1]); SetPreviousData (PreviousDataKey, 'Light mode', UsageValues ​​[0]); SetPreviousData (PreviousDataKey, 'Sponsored mode', UsageValues ​​[1]); SetPreviousData (PreviousDataKey, 'Paid mode', UsageValues ​​[2]); SetPreviousData (PreviousDataKey, 'DataDir ', DATADIR; END;

function ScriptDlgPages (CurPage: Integer; BackClicked: Boolean): Boolean; var I, CurSubPage: Integer; Next, NextOk: Boolean; begin if (not BackClicked and (CurPage = wpSelectDir)) or (BackClicked and (CurPage = wpReady)) then begin {Insert a custom wizard page between two non custom pages} {First open the custom wizard page} ScriptDlgPageOpen (); {Set some captions} ScriptDlgPageSetCaption ( 'Select Personal Data Directory'); ScriptDlgPageSetSubCaption1 ( 'Where should personal data files be installed ? '); ScriptDlgPageSetSubCaption2 (' Select the folder you would like Setup to install personal data files to, then click Next '); {Initialize the DataDir if necessary} if DataDir =' 'then DataDir:. =' C: / ' Uservalues ​​[0]; {Ask for a dir untenil the user has entered one or clicel (uservalues ​​[0], datadir); while next and (datadir = ') DO Begin Msgbox (SetupMessage) (SETUPMESSAGE) MsginvalidPath, MBerror, MB_OK; Next: = INPU tDir (UserValues ​​[0], DataDir); end; {See NextButtonClick and BackButtonClick: return True if the click should be allowed} if not BackClicked then Result: = Next else Result: = not Next; {Close the wizard page Do a. FullRestore Only if The Click (See Above) IS NOT ALOWED} ScriptdlgPageclose (NOT ELSE IF (Not BACKCLICKED AND (CURPAGE = WPWELCOME)) OR (BackClicked and (CURPAGE =

wpSelectDir)) then begin {Insert multiple custom wizard page between two non custom pages} {Now we must handle navigation between the custom pages ourselves} {First find out on which page we should start} if not BackClicked then CurSubPage: = 0 else CurSubPage : = 2; {Then open the custom wizard page} ScriptDlgPageOpen (); {Set the main caption} ScriptDlgPageSetCaption ( 'Personal Information'); {Loop while we are still on a custom page and Setup has not been terminated} while (CurSubPage > = 0) and (CurSubPage <= 2) and not Terminated do begin case CurSubPage of 0: begin {First ask for some user info} ScriptDlgPageSetSubCaption1 ( 'Who are you?'); ScriptDlgPageSetSubCaption2 ( 'Please specify your name and the company For whom you work, then: = inputQueryArray (userPrompts, uservalues); if Next the beginning nextok: = Uservalues ​​[0] <> ''; If not NextOk then MsgBox ( 'You must enter your name', mbError, MB_OK; end; end; 1: begin {Then ask for the usage mode} ScriptDlgPageSetSubCaption1.) ( 'How will you use My Progam'?) ; ScriptDlgPageSetSubCaption2 ( 'Please specify how you would like to use My Program, then click Next.'); Next: = InputOptionArray (UsagePrompts, UsageValues, True, False); NextOk: = True; end; 2: begin if UsageValues ​​[0 ] = '1' Then Begin {Show a Message IF 'Light Mode'

was chosen above} {Skip this page when the user just clicked the Back button} ScriptDlgPageSetSubCaption1 ( 'How will you My Progam use?'); Next: = OutputMsg ( 'Note: to enjoy all features My Program can offer and to support its development, you can switch to sponsored or paid mode at any time by selecting '' Usage Mode '' in the '' Help '' menu of My Program after the installation has completed. '# 13 # 13'Click Back if you want to change your usage mode setting now, or click Next to continue with the installation ', True); NextOk: = True; end else if UsageValues ​​[2] ='. 1 'then begin {Ask for a registration key if' paid mode ' was chosen above} {This demo accepts only one key: (? 'What''s your registration key ')' isx '(without quotes)} ScriptDlgPageSetSubCaption1; ScriptDlgPageSetSubCaption2 (' Please specify your registration key, ' UserValues ​​[0] '. Click Next to Continue. IF Y ou don''t have a valid registration key, click Back to choose a different usage mode '); Next: = InputQuery ('. Registration key: ', Key); if Next then begin {Just to show how OutputProgress works} for I: = 0 to 10 do begin OutputProgress ('Authorizing Registration Key ...,' ', i, 10); SLEEP (100); if Terminated the Break; End; Nextok: = key =' isx ';

IF not nextok and not terminated the msgbox ('You Must Enter a Valid Registration Key.', MBerror, MB_OK); end; end; end; end; if Next the beginning correct information} if NextOk then CurSubPage: = CurSubPage 1; end else CurSubPage: = CurSubPage - 1; end; {See NextButtonClick and BackButtonClick: return True if the click should be allowed} if not BackClicked then Result: = Next else Result: = not Next; {Close the wizard page Do a FullRestore only if the click (see above) is not allowed.} ScriptDlgPageClose (not Result); end else begin Result: = True; end; end; function NextButtonClick (CurPage: Integer) : Boolean; Begin Result: = Scriptdlgpages (CURPAGPAGES (CURPAGE, FALSE); END;

Function BackbuttonClick (CURPAGE: INTEGER): Boolean; Begin Result: = Scriptdlgpages (CURPAGE, TRUE); END

function UpdateReadyMemo (Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo, MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String): String; var S: String; begin {Fill the 'Ready Memo' with the normal settings and the custom settings} S: = ' '; S: = s ' Personal Information: ' newline; s: = s space uservalues ​​[0] newline; if Uservalues ​​[1] <>' 'Then S: = S Space UserValues ​​[1] Newline; s: = s newline;

S: = s 'usage mode:' newline; if usagevalues ​​[0] = '1' TENS: = S Space usageprompts [0] newline else if usagevalues ​​[1] = '1' THEN S: = S Space UsagePrompts [1] Newline Else S: ​​= S Space UsagePROMPTS [2] Newline; S: = S NewLine; S: = S MemodirInfo NewLine; S: = S Space DataDir '(Personal Data Files)' Newline;

Result: = S; end;

function GetUser (S: String): String; begin {Return a user value} {Could also be splitted into separate GetUserName and GetUserCompany functions} if S = 'Name' then Result: = UserValues ​​[0] else if S = 'Company' THEN RESULT: = Uservalues ​​[1];

Function getDataDir (s: string): string; begin {returnid: = datadir;

转载请注明原文地址:https://www.9cbs.com/read-78592.html

New Post(0)