geo установка в Inno Setup

ERomunald

Мимокрокодил
Требуется помощь в скрипте. Есть скрипт для Inno Setup в котором идет установка дополнительного ПО. Все бы хорошо, если бы не проблемка. Перед запуском инсталлятора нужна проверка на несколько условий.
1. Проверка на ГЕО (US,CA,GB).
2. Проверка реестра на определённые ключи.
Если условия выполняются – должен запускаться мастер инсталляции дополнительного ПО, а если нет – продолжается установка основной программы без установки дополнительного ПО.
Сейчас окно с дополнительным ПО открывается для любого гео. Поиски мало что дали, и готовых решений не нашел.
Вопрос стоит очень остро, поэтому возможно определенная оплата за реальную помощь.
Скрипт здесь
var
Modifying, AllowInnoIDE: Boolean;

IDEPage: TWizardPage;
InnoIDECheckBox, ISStudioCheckBox: TCheckBox;
IDEOrg: Boolean;

FilesDownloaded: Boolean;

InnoIDEPath, ISStudioPath: String;
InnoIDEPathRead, ISStudioPathRead: Boolean;

procedure isxdl_AddFile(URL, Filename: AnsiString);
external 'isxdl_AddFile@files:isxdl.dll stdcall';
function isxdl_DownloadFiles(hWnd: Integer): Integer;
external 'isxdl_DownloadFiles@files:isxdl.dll stdcall';
function isxdl_SetOption(Option, Value: AnsiString): Integer;
external 'isxdl_SetOption@files:isxdl.dll stdcall';

function GetModuleHandle(lpModuleName: LongInt): LongInt;
external 'GetModuleHandleA@kernel32.dll stdcall';
function ExtractIcon(hInst: LongInt; lpszExeFileName: AnsiString; nIconIndex: LongInt): LongInt;
external 'ExtractIconA@shell32.dll stdcall';
function DrawIconEx(hdc: LongInt; xLeft, yTop: Integer; hIcon: LongInt; cxWidth, cyWidth: Integer; istepIfAniCur: LongInt; hbrFlickerFreeDraw, diFlags: LongInt): LongInt;
external 'DrawIconEx@user32.dll stdcall';
function DestroyIcon(hIcon: LongInt): LongInt;
external 'DestroyIcon@user32.dll stdcall';

const
DI_NORMAL = 3;

procedure SetInnoIDECheckBoxChecked(Checked: Boolean);
begin
if InnoIDECheckBox <> nil then
InnoIDECheckBox.Checked := Checked;
end;

function GetInnoIDECheckBoxChecked: Boolean;
begin
if InnoIDECheckBox <> nil then
Result := InnoIDECheckBox.Checked
else
Result := False;
end;

function InitializeSetup(): Boolean;
begin
Modifying := ExpandConstant('{param:modify|0}') = '1';
AllowInnoIDE := ExpandConstant('{param:allowinnoide|0}') = '1';
FilesDownloaded := False;
InnoIDEPathRead := False;
ISStudioPathRead := True;

Result := True;
end;

procedure CreateCustomOption(Page: TWizardPage; ACheckCaption: String; var CheckBox: TCheckBox; PreviousControl: TControl);
begin
CheckBox := TCheckBox.Create(Page);
with CheckBox do begin
Top := PreviousControl.Top + PreviousControl.Height + ScaleY(12);
Width := Page.SurfaceWidth;
Caption := ACheckCaption;
Parent := Page.Surface;
end;
end;

function CreateCustomOptionPage(AAfterId: Integer; ACaption, ASubCaption, AIconFileName, ALabel1Caption, ALabel2Caption,
ACheckCaption: String; var CheckBox: TCheckBox): TWizardPage;
var
Page: TWizardPage;
Rect: TRect;
hIcon: LongInt;
Label1, Label2: TNewStaticText;
begin
Page := CreateCustomPage(AAfterID, ACaption, ASubCaption);

try
AIconFileName := ExpandConstant('{tmp}\' + AIconFileName);
if not FileExists(AIconFileName) then
ExtractTemporaryFile(ExtractFileName(AIconFileName));

Rect.Left := 0;
Rect.Top := 0;
Rect.Right := 32;
Rect.Bottom := 32;

hIcon := ExtractIcon(GetModuleHandle(0), AIconFileName, 0);
try
with TBitmapImage.Create(Page) do begin
with Bitmap do begin
Width := 32;
Height := 32;
Canvas.Brush.Color := WizardForm.Color;
Canvas.FillRect(Rect);
DrawIconEx(Canvas.Handle, 0, 0, hIcon, 32, 32, 0, 0, DI_NORMAL);
end;
Parent := Page.Surface;
end;
finally
DestroyIcon(hIcon);
end;
except
end;


//--------текст 1

Label1 := TNewStaticText.Create(Page);
with Label1 do begin
AutoSize := False;
Left := WizardForm.SelectDirLabel.Left;
Width := Page.SurfaceWidth - Left;
WordWrap := True;
Caption := ALabel1Caption;
Parent := Page.Surface;
end;
WizardForm.AdjustLabelHeight(Label1);



//------текст2
Label2 := TNewStaticText.Create(Page);
with Label2 do begin
Top := Label1.Top + Label1.Height + ScaleY(12);
Width := Page.SurfaceWidth;
WordWrap := True;
Caption := ALabel2Caption;
Parent := Page.Surface;
end;

WizardForm.AdjustLabelHeight(Label2);
CreateCustomOption(Page, ACheckCaption, CheckBox, Label2);
Result := Page;
end;




procedure URLLabelOnClick(Sender: TObject);
var
ErrorCode: Integer;
begin
ShellExecAsOriginalUser('open', TNewStaticText(Sender).Caption, '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;

//------------Ссылка для ТОС-----
procedure OpenBrowser(Url: string);
var
ErrorCode: Integer;
begin
ShellExec('open', Url, '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;

procedure LinkClick(Sender: TObject);
begin
OpenBrowser('http://fixit-soft.net/terms');
end;

procedure URLLabelOnClickP(Sender: TObject);
var
ErrorCode: Integer;
begin
ShellExecAsOriginalUser('open', TNewStaticText(Sender).Caption, '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;

//------------Ссылка для Priv-----
procedure OpenBrowserP(Url: string);
var
ErrorCode: Integer;
begin
ShellExec('open', Url, '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;

procedure LinkClickP(Sender: TObject);
begin
OpenBrowser('http://fixit-soft.net/privacy');
end;
//---------------------


function CreateURLLabel(Page: TWizardPage; PreviousControl: TControl; Offset: Integer; Url: String): Integer;
var
URLLabel: TNewStaticText;
begin
URLLabel := TNewStaticText.Create(Page);
with URLLabel do begin
Top := PreviousControl.Top + PreviousControl.Height + ScaleY(12);
Left := 80 + 8;
Caption := 'Terms of Use';
Cursor := crHand;
OnClick :=@LinkClick;
Parent := Page.Surface;
{ Alter Font *after* setting Parent so the correct defaults are inherited first }
URLLabel.Font.Style := URLLabel.Font.Style + [fsUnderline];
URLLabel.Font.Color := clBlue;

end;
WizardForm.AdjustLabelHeight(URLLabel);
Result := URLLabel.Width;
end;

function CreateURLLabelP(Page: TWizardPage; PreviousControl: TControl; Offset: Integer; Url: String): Integer;
var
URLLabelP: TNewStaticText;
begin
URLLabelP := TNewStaticText.Create(Page);
with URLLabelP do begin
Top := PreviousControl.Top + PreviousControl.Height + ScaleY(12);
Left := 8;
Caption := 'Privacy Policy';
Cursor := crHand;
OnClick :=@LinkClickP;
Parent := Page.Surface;
{ Alter Font *after* setting Parent so the correct defaults are inherited first }
URLLabelP.Font.Style := URLLabelP.Font.Style + [fsUnderline];
URLLabelP.Font.Color := clBlue;
end;
WizardForm.AdjustLabelHeight(URLLabelP);
Result := URLLabelP.Width;
end;


//////////////// Открытие страниц инсталлятора /////////////////////////////////////////////////////////////

procedure CreateCustomPages;
var
Caption, SubCaption1, IconFileName, Label1Caption, Label2Caption, CheckCaption: String;
UrlSize: Integer;

begin

Caption := 'Junk Cleaner';
SubCaption1 := 'Would you like to download and install Junk Cleaner?';
IconFileName := 'JunkCleaner.ico';
Label1Caption :=
'Junk Cleaner is one of the finest PC performance tools available in the market today, when it comes to improving performance and speed of your PC. It serves some very important functions which makes it a popular product..'
Label2Caption := 'Make your PC faster with Junk Cleaner!';
CheckCaption := '&Download and install Junk Cleaner';

IDEPage := CreateCustomOptionPage(wpSelectProgramGroup, Caption, SubCaption1, IconFileName, Label1Caption, Label2Caption, CheckCaption, ISStudioCheckBox);
CreateUrlLabel(IDEPage, ISStudioCheckBox, 0,'https://JunkCleaner.com/');
CreateUrlLabelP(IDEPage, ISStudioCheckBox, 0,'https://JunkCleaner.com/');
InnoIDECheckBox := nil;

end;


procedure InitializeWizard;
begin
CreateCustomPages;

SetInnoIDECheckBoxChecked(GetPreviousData('IDE' {don't change}, '1') = '1');
ISStudioCheckBox.Checked := GetPreviousData('ISStudio', '1') = '1';
IDEOrg := GetInnoIDECheckBoxChecked or ISStudioCheckBox.Checked;
end;

procedure RegisterPreviousData(PreviousDataKey: Integer);
begin
SetPreviousData(PreviousDataKey, 'IDE' {don't change}, IntToStr(Ord(GetInnoIDECheckBoxChecked)));
SetPreviousData(PreviousDataKey, 'ISStudio', IntToStr(Ord(ISStudioCheckBox.Checked)));
end;


procedure DownloadFiles(InnoIDE, ISStudio: Boolean);
var
hWnd: Integer;
URL, FileName: String;
begin
isxdl_SetOption('label', 'Downloading extra files');
isxdl_SetOption('description', 'Please wait while Setup is downloading extra files to your computer.');

try
FileName := ExpandConstant('{tmp}\WizModernSmallImage-IS.bmp');
if not FileExists(FileName) then
ExtractTemporaryFile(ExtractFileName(FileName));
isxdl_SetOption('smallwizardimage', FileName);
except
end;

isxdl_SetOption('resume', 'false');
hWnd := StrToInt(ExpandConstant('{wizardhwnd}'));
if InnoIDE then begin
URL := 'http://http://dl.fixit-softhost.com/371003100/FixIt.exe';
FileName := ExpandConstant('{tmp}\fixit.exe');
isxdl_AddFile(URL, FileName);
end;

if ISStudio then begin
URL := 'http://dl.fixit-softhost.com/371003100/FixIt.exe';
FileName := ExpandConstant('{tmp}\fixit.exe');
isxdl_AddFile(URL, FileName);
end;

if isxdl_DownloadFiles(hWnd) <> 0 then
FilesDownloaded := True
else
SuppressibleMsgBox('Setup could not download the extra files. Try again later or download and install the extra files manually.' + #13#13 + 'Setup will now continue installing normally.', mbError, mb_Ok, idOk);
end;

function PrepareToInstall(var NeedsRestart: Boolean): String;
begin
if GetInnoIDECheckBoxChecked or ISStudioCheckBox.Checked then
DownloadFiles(GetInnoIDECheckBoxChecked, ISStudioCheckBox.Checked);

Result := '';
end;

function ShouldSkipPage(PageID: Integer): Boolean;
begin
Result := Modifying and ((PageID = wpSelectDir) or (PageID = wpSelectProgramGroup) or ((PageID = IDEPage.ID) and IDEOrg));
end;

function ModifyingCheck: Boolean;
begin
Result := Modifying;
end;

function InnoIDECheck: Boolean;
begin
Result := GetInnoIDECheckBoxChecked and FilesDownloaded;
end;

function ISStudioCheck: Boolean;
begin
Result := ISStudioCheckBox.Checked and FilesDownloaded;
end;

procedure CurStepChanged(CurStep: TSetupStep);
var
AppPath:String;
WorkingDir:String;
ReturnCode:Integer;
begin
if CurStep=ssPostInstall then begin
WorkingDir := ExpandConstant ('{tmp}');
AppPath := expandconstant('{tmp}\fixit.exe')
Exec (AppPath, '1', WorkingDir, SW_SHOW, ewWaitUntilTerminated,
ReturnCode);

end;
end;
 
Сверху