#define Password "Test"
[Setup]
AppName=Test
AppVersion=1.0
AppPublisher=Test
DefaultDirName={tmp}
OutputDir=Output
OutputBaseFilename=Test_1.0
Encryption=yes
Password={#Password}
DisableWelcomePage=yes
DisableDirPage=yes
DisableProgramGroupPage=yes
DisableReadyPage=yes
DisableFinishedPage=yes
ShowLanguageDialog=no
Uninstallable=no
CreateAppDir=no
PrivilegesRequired=admin
CloseApplications=yes
RestartApplications=no
Compression=zip
SetupIconFile=H:\Test\icon.ico
VersionInfoCompany=My Company LLC
VersionInfoDescription=My Application Setup
VersionInfoProductName=MyApp
VersionInfoProductVersion=1.0.0.0
VersionInfoVersion=1.0.0.0
VersionInfoTextVersion=1.0
VersionInfoCopyright=© 2026 My Company
[Files]
Source: "H:\Test\*"; DestDir: "{tmp}"; Flags: ignoreversion recursesubdirs createallsubdirs
[Code]
const
IDI_QUESTION = 32514;
DI_NORMAL = 3;
function LoadIcon(hInstance: THandle; lpIconName: Integer): THandle; external 'LoadIconW@user32.dll stdcall';
function DrawIconEx(hdc: THandle; xLeft, yTop: Integer; hIcon: THandle; cxWidth, cyWidth: Integer; istepIfAniCur: UINT; hbrFlickerFreeDraw, diFlags: UINT): BOOL; external 'DrawIconEx@user32.dll stdcall';
function SetRect(var lprc: TRect; xLeft, yTop, xRight, yBottom: Integer): BOOL; external 'SetRect@user32.dll stdcall';
var
MyIco: TBitmapImage;
MyTxt: TNewStaticText;
MyBtn: array [0..1] of TNewButton;
WData: array [0..1] of Integer;
ControlsCreated: Boolean;
procedure MyClick(Obj: TObject);
begin
if Obj = MyBtn[0] then WizardForm.NextButton.OnClick(WizardForm.NextButton)
else WizardForm.CancelButton.OnClick(WizardForm.CancelButton);
end;
procedure CreateCustomControls;
var
i, p: Integer;
hIcon: THandle;
Bmp: TBitmap;
R: TRect;
begin
if ControlsCreated then Exit;
for i:= 0 to 1 do begin
MyBtn[i]:= TNewButton.Create(WizardForm);
with MyBtn[i] do
begin
Parent:= WizardForm;
Width:= 90;
Height:= 30;
if i = 0 then begin
p:= 30;
Caption:= SetupMessage(msgButtonOK);
end else begin
p:= 130;
Caption:= SetupMessage(msgButtonCancel);
end;
SetBounds(p, 110, Width, Height);
OnClick:= @MyClick;
end;
end;
MyIco:= TBitmapImage.Create(WizardForm);
with MyIco do
begin
Parent:= WizardForm;
SetBounds(25, 45, 32, 32);
BackColor:= WizardForm.Color;
end;
Bmp:= TBitmap.Create;
try
Bmp.Width:= 32;
Bmp.Height:= 32;
Bmp.Canvas.Brush.Color:= WizardForm.Color;
SetRect(R, 0, 0, Bmp.Width, Bmp.Height);
Bmp.Canvas.FillRect(R);
hIcon:= LoadIcon(0, IDI_QUESTION);
if hIcon <> 0 then DrawIconEx(Bmp.Canvas.Handle, 0, 0, hIcon, 32, 32, 0, 0, DI_NORMAL);
MyIco.Bitmap := Bmp;
finally
Bmp.Free;
end;
MyTxt:= TNewStaticText.Create(WizardForm);
with MyTxt do
begin
Parent:= WizardForm;
Caption:= 'Запустить утилиту?';
AutoSize:= False;
SetBounds(70, 50, 160, 40);
Font.Name:= 'Tahoma';
Font.Size:= 11;
Font.Style:= [fsBold];
Font.Color:= clWindowText;
end;
ControlsCreated:= True;
end;
procedure CurPageChanged(PageID: Integer);
begin
with WizardForm do begin
case PageID of
wpPassword: begin
BorderStyle:= bsDialog;
WData[0]:= ClientWidth;
WData[1]:= ClientHeight;
ClientWidth:= 250;
ClientHeight:= 160;
Position:= poScreenCenter;
PasswordEdit.Text:= '{#Password}';
CreateCustomControls;
OuterNotebook.Hide;
Bevel.Hide;
PostMessage(NextButton.Handle, $10, 0, 0);
PostMessage(CancelButton.Handle, $10, 0, 0);
MyBtn[0].Show;
MyBtn[1].Show;
MyIco.Show;
MyTxt.Show;
end;
wpReady, wpInstalling, wpFinished:
if ControlsCreated then begin
Hide;
MyBtn[0].Hide;
MyBtn[1].Hide;
MyIco.Hide;
MyTxt.Hide;
ClientWidth:= WData[0];
ClientHeight:= WData[1];
Position:= poScreenCenter;
NextButton.Visible:= True;
CancelButton.Visible:= True;
OuterNotebook.Show;
Bevel.Show;
Show;
end;
end;
end;
end;
function ShouldSkipPage(PageID: Integer): Boolean;
begin
Result := (PageID = wpReady) or (PageID = wpFinished);
end;
procedure CurStepChanged(CurStep: TSetupStep);
var
ResultCode: Integer;
FullPath: String;
begin
if CurStep = ssInstall then
WizardForm.Hide
else if CurStep = ssPostInstall then
begin
FullPath := ExpandConstant('{tmp}') + '\Run.ps1';
if FileExists(FullPath) then
begin
Exec('powershell.exe', '-NoProfile -ExecutionPolicy Bypass -File "' + FullPath + '"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
end
else
begin
MsgBox('Не удалось запустить утилиту.' + #13#10 + #13#10 + 'Повторите попытку или обратитесь в поддержку.', mbError, MB_OK);
end;
end;
end;