[Setup]
AppName = MyApp
AppVerName = MyApp
DefaultDirname = {pf}\MyApp
OutputDir=.
[Code]
var
GameList: TNewCheckListBox;
function InitializeSetup: Boolean;
begin
SaveStringToFile(ExpandConstant('{tmp}\key1.txt'), '1B4CC5AFS3BUQSZMKSDD'+ #13#10, True);
SaveStringToFile(ExpandConstant('{tmp}\key1.txt'), '2HIVRNBRUVIRN3VJIWEI'+ #13#10, True);
SaveStringToFile(ExpandConstant('{tmp}\key1.txt'), 'GNWE6RJ2XECXKJ5QEDWF', True);
SaveStringToFile(ExpandConstant('{tmp}\key2.txt'), '2VNBE07L6SZWIHR81X4Q'+ #13#10, True);
SaveStringToFile(ExpandConstant('{tmp}\key2.txt'), 'IYVD023U6XNPEQR5LMC9'+ #13#10, True);
SaveStringToFile(ExpandConstant('{tmp}\key2.txt'), '1ESU73IFGVDQ8A52X90R', True);
SaveStringToFile(ExpandConstant('{tmp}\key3.txt'), 'WYE0ID4KS3GMH9RFOBVT'+ #13#10, True);
SaveStringToFile(ExpandConstant('{tmp}\key3.txt'), '7IWS2VNK4BFJMQOUA19X'+ #13#10, True);
SaveStringToFile(ExpandConstant('{tmp}\key3.txt'), 'MXH24VLZ6CQKRSIF09P5', True);
Result := True;
end;
function GetRandomKey(FileName: String): String;
var
Lines: TArrayOfString;
ArrayLength, RandomNum: Integer;
begin
Result:= '';
if FileExists(FileName) then
begin
if LoadStringsFromFile(FileName, Lines) then
begin
ArrayLength:= GetArrayLength(Lines);
RandomNum:= Random(ArrayLength);
Result:= Lines[RandomNum];
end;
end;
end;
procedure MyClick(Sender: TObject);
begin
if GameList.Checked[1] then WizardForm.DirEdit.Text:= GetRandomKey(ExpandConstant('{tmp}\key1.txt'));
if GameList.Checked[2] then WizardForm.DirEdit.Text:= GetRandomKey(ExpandConstant('{tmp}\key2.txt'));
if GameList.Checked[3] then WizardForm.DirEdit.Text:= GetRandomKey(ExpandConstant('{tmp}\key3.txt'));
end;
procedure InitializeWizard;
begin
WizardForm.DirBrowseButton.OnClick:= @MyClick;
WizardForm.DirBrowseButton.Caption:= 'Random Key';
GameList:= TNewCheckListBox.Create(WizardForm.SelectDirPage);
with GameList do
begin
SetBounds(ScaleX(2), WizardForm.DirEdit.Top+WizardForm.DirEdit.Height+ScaleY(10), ScaleX(145), ScaleY(90));
BorderStyle:= bsNone;
ParentColor:= True;
MinItemHeight:= ScaleY(3);
ShowLines:= False;
WantTabs:= True;
Parent:= WizardForm.SelectDirPage;
AddGroup('Какую игру выбираете?', '', 0, nil);
AddRadioButton('Игра №1', '', 0, True, True, nil);
AddRadioButton('Игра №2', '', 0, False, True, nil);
AddRadioButton('Игра №3', '', 0, False, True, nil);
OnClickCheck:= @MyClick;
end;
if GameList.Checked[1] then WizardForm.DirEdit.Text:= GetRandomKey(ExpandConstant('{tmp}\key1.txt'));
if GameList.Checked[2] then WizardForm.DirEdit.Text:= GetRandomKey(ExpandConstant('{tmp}\key2.txt'));
if GameList.Checked[3] then WizardForm.DirEdit.Text:= GetRandomKey(ExpandConstant('{tmp}\key3.txt'));
end;