Inno Setup Pascal/delphi脚本代码综合示例

本文提供了一个使用Inno Setup创建安装脚本的详细示例,包括设置应用程序信息、文件复制、任务定义、图标创建、注册表项、系统要求检查等关键步骤。同时展示了如何在安装过程中实现滑动动画效果、播放音乐和处理用户取消安装请求的代码。
[Setup]
AppName=S.T.A.L.K.E.R.: Shadow of Chernobyl
AppVerName=S.T.A.L.K.E.R.: Shadow of Chernobyl (полная русская версия)
AppPublisher=Chuvakstepan Inc.
DefaultDirName={pf}/Chuvakstepan/S.T.A.L.K.E.R
DefaultGroupName=Chuvakstepan/S.T.A.L.K.E.R
Compression=zip
SolidCompression=false
OutputBaseFilename=setup
UninstallFilesDir={app}
WindowVisible=yes
WindowResizable=no
WindowShowCaption=no
BackColor=$000000
BackSolid=yes
VersionInfoVersion=1.0.0.1
VersionInfoCompany=Chuvakstepan Inc.
VersionInfoCopyright=GSC
DiskSpanning=yes
DiskSliceSize=723517440
UseSetupLdr=true
Outputdir=C:/Для кодировки/Test/
LicenseFile=compiler:License.rtf
WizardImageFile=compiler:st_wel.bmp
WizardSmallImageFile=compiler:st_head.bmp
 
 
[Files]
Source: compiler:BASS.dll; DestDir: " {tmp} "; Flags: dontcopy noencryption
Source: compiler:sound.mp3; DestDir: {tmp}; Flags: dontcopy noencryption nocompression
Source: compiler:Splash.bmp; DestDir: {tmp}; Flags: dontcopy noencryption
Source: compiler:isxbb.dll; DestDir: {tmp}; Flags: dontcopy  noencryption
Source: compiler:splash.bmp; DestDir: {tmp}; Flags: dontcopy  noencryption
Source: compiler:1.jpg; DestDir: {tmp}; Flags: dontcopy  noencryption
Source: compiler:2.jpg; DestDir: {tmp}; Flags: dontcopy  noencryption
Source: compiler:3.jpg; DestDir: {tmp}; Flags: dontcopy  noencryption
Source: compiler:4.jpg; DestDir: {tmp}; Flags: dontcopy  noencryption
Source: compiler:5.jpg; DestDir: {tmp}; Flags: dontcopy  noencryption
Source: compiler:6.jpg; DestDir: {tmp}; Flags: dontcopy  noencryption
Source: compiler:7.jpg; DestDir: {tmp}; Flags: dontcopy  noencryption
Source: compiler:8.jpg; DestDir: {tmp}; Flags: dontcopy  noencryption
Source: compiler:9.jpg; DestDir: {tmp}; Flags: dontcopy  noencryption
Source: compiler:License.rtf; DestDir: {tmp}; Flags: dontcopy noencryption
Source: compiler:st_fin.bmp; DestDir: {tmp}; Flags: dontcopy  noencryption
Source: compiler:Background.bmp; DestDir: {tmp}; Flags: dontcopy noencryption
Source: compiler:get_hw_caps.dll; Flags: dontcopy  noencryption
Source: compiler:website.url; DestDir: {app}; Tasks: url
Source: compiler:websitegameSTALKER.url; DestDir: {app}; Tasks: url
Source: C:/Игры/Test Drive Unlimited/Readme.htm; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs
Source: compiler:KillSave from 1C/killsave.exe; DestDir: {app}; Flags: ignoreversion
Source: compiler:KillSave from 1C/Kill.ini; DestDir: {app}; Flags: ignoreversion
 
 
 
 
 
[Tasks]
Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}
Name: url; Description: Создать ссылки на интернет-сайты в меню пуск; GroupDescription: {cm:AdditionalIcons}
 
 
[Icons]
Name: {userdesktop}/S.T.A.L.K.E.R.; Filename: {app}/bin/XR_3DA.exe; Tasks: desktopicon;  Flags: createonlyiffileexists; WorkingDir: {app}/bin
Name: {group}/Начать игру; Filename: {app}/bin/XR_3DA.exe; Flags: createonlyiffileexists; WorkingDir: {app}/bin
Name: {group}/Руководство; Filename: {app}/manual.pdf; Flags: createonlyiffileexists
Name: {group}/Трейнер; Filename: {app}/trn.exe; Flags: createonlyiffileexists; WorkingDir: {app}
Name: {group}/Файл Readme; Filename: {app}/ReadMe.txt; Flags: createonlyiffileexists
Name: {group}/Интернет-сайты/Chuvakstepan Inc.; Filename: {app}/website.url; Flags: createonlyiffileexists; Tasks: url
Name: {group}/Интернет-сайты/Сайт игры; Filename: {app}/websitegameSTALKER.url; Flags: createonlyiffileexists; Tasks: url
Name: {group}/{cm:UninstallProgram,игры}; Filename: {uninstallexe}
 
 
[Registry]
Root: HKLM; SubKey: SOFTWARE/GSC Game World/STALKER-SHOC1; ValueType: string; ValueName: InstallPath; ValueData: {app} ; Flags: uninsdeletekey
Root: HKLM; SubKey: SOFTWARE/GSC Game World/STALKER-SHOC1; ValueType: string; ValueName: InstallLang; ValueData: en; Flags: uninsdeletekey
Root: HKLM; SubKey: SOFTWARE/GSC Game World/STALKER-SHOC1; ValueType: string; ValueName: InstallSource; ValueData: stk-for-pack-securom-keydisk-efis; Flags: uninsdeletekey
Root: HKLM; SubKey: SOFTWARE/GSC Game World/STALKER-SHOC1; ValueType: string; ValueName: InstallVers; ValueData: 1.0001; Flags: uninsdeletekey
Root: HKLM; SubKey: SOFTWARE/GSC Game World/STALKER-SHOC1; ValueType: string; ValueName: InstallCDKEY; ValueData: 2J3G-4KJ3-B4J2-4I1N; Flags: uninsdeletekey
Root: HKLM; SubKey: SOFTWARE/GSC Game World/STALKER-SHOC1; ValueType: string; ValueName: InstallUserName; ValueData: Chuvakstepan; Flags: uninsdeletekey
Root: HKLM; SubKey: SOFTWARE/GSC Game World/STALKER-SHOC1; ValueType: dword; ValueName: BonusPack1; ValueData: $00000000; Flags: uninsdeletekey
Root: HKLM; SubKey: SOFTWARE/GSC Game World/STALKER-SHOC1; ValueType: dword; ValueName: BonusPack2; ValueData: $00000000; Flags: uninsdeletekey
Root: HKLM; SubKey: SOFTWARE/GSC Game World/STALKER-SHOC1; ValueType: string; ValueName: UnInstConfirm; ValueData: Do you want to remove all saved games and profiles?; Flags: uninsdeletekey
 
Root: HKLM; SubKey: SOFTWARE/Chuvakstepan/STALKER-SHOC; ValueType: string; ValueName: SavePath; ValueData: {app}/bin; Flags: uninsdeletekey
 
[LangOptions]
TitleFontSize=1
DialogFontName=Tahoma
DialogFontSize=8
WelcomeFontName=Times New Roman
WelcomeFontSize=13
TitleFontName=Arial
CopyrightFontName=Arial
CopyrightFontSize=8
 
[Messages]
BeveledLabel=Chuvakstepan Inc. 2007
 
[CustomMessages]
UninstallProgram=Удаление %1
 
[UninstallRun]
Filename: "{app}/KillSave.exe"; Parameters: "Kill"; WorkingDir: "{app}";
 
 
[Code]
 
//////////Проверка системных требований
 
 const
  NeedSize = 20; //Прописать, сколько мегабайт необходимо
 
  DRIVE_UNKNOWN = 0;
  DRIVE_NO_ROOT_DIR = 1;
  DRIVE_REMOVEABLE = 2;
  DRIVE_FIXED = 3;
  DRIVE_REMOTE = 4;
  DRIVE_CDROM = 5;
  DRIVE_RAMDISK = 6;
  //Все эффекты анимации
  AW_FADE_IN = $00080000;
  AW_FADE_OUT = $00090000;
  AW_SLIDE_IN_LEFT = $00040001;
  AW_SLIDE_OUT_LEFT = $00050002;
  AW_SLIDE_IN_RIGHT = $00040002;
  AW_SLIDE_OUT_RIGHT = $00050001;
  AW_SLIDE_IN_TOP = $00040004;
  AW_SLIDE_OUT_TOP = $00050008;
  AW_SLIDE_IN_BOTTOM = $00040008;
  AW_SLIDE_OUT_BOTTOM = $00050004;
  AW_DIAG_SLIDE_IN_TOPLEFT = $00040005;
  AW_DIAG_SLIDE_OUT_TOPLEFT = $0005000A;
  AW_DIAG_SLIDE_IN_TOPRIGHT = $00040006;
  AW_DIAG_SLIDE_OUT_TOPRIGHT = $00050009;
  AW_DIAG_SLIDE_IN_BOTTOMLEFT = $00040009;
  AW_DIAG_SLIDE_OUT_BOTTOMLEFT = $00050006;
  AW_DIAG_SLIDE_IN_BOTTOMRIGHT = $0004000A;
  AW_DIAG_SLIDE_OUT_BOTTOMRIGHT = $00050005;
  AW_EXPLODE = $00040010;
  AW_IMPLODE = $00050010;
 
var
  ListBox: TListBox;
  
function AnimateWindow(hWnd: HWND; dwTime: DWORD; dwFlags: DWORD): Boolean;
  external 'AnimateWindow@user32 stdcall';
 
procedure ListBoxOnClick(Sender: TObject);
var
  NewLetter, OldString: String;
  i: Integer;
begin
  for i:= 0 to ListBox.Items.Count-1 do
    begin
      if ListBox.Selected[i] then
        begin
          NewLetter:= Copy(ListBox.Items[i], 0, 1);
          OldString:= Copy(WizardForm.DirEdit.Text, 2, Length(WizardForm.DirEdit.Text));
          WizardForm.DirEdit.Text:= NewLetter + OldString;
        end;
    end;
end;
 
 function GetLogicalDrives: DWORD;
external 'GetLogicalDrives@kernel32.dll stdcall';
 
function GetDriveType(nDrive: String): Longint;
external 'GetDriveTypeA@kernel32.dll stdcall';
 
function GetVideoCardName(): PChar;
external 'hwc_GetVideoCardName@files:get_hw_caps.dll stdcall';
 
function GetSoundCardName(): PChar;
external 'hwc_GetSoundCardName@files:get_hw_caps.dll stdcall';
 
function DetectHardware(): Integer;
external 'hwc_DetectHardware@files:get_hw_caps.dll stdcall';
 
function GetHardDriveFreeSpace(hdd: integer): Integer;
external 'hwc_GetHardDriveFreeSpace@files:get_hw_caps.dll stdcall';
 
function GetHardDriveName(hdd: integer): PChar;
external 'hwc_GetHardDriveName@files:get_hw_caps.dll stdcall';
 
function GetHardDriveTotalSpace(hdd: integer): Integer;
external 'hwc_GetHardDriveTotalSpace@files:get_hw_caps.dll stdcall';
 
function GetHardDrivesCount(): Integer;
external 'hwc_GetHardDrivesCount@files:get_hw_caps.dll stdcall';
 
function GetSoundCards(): Integer;
external 'hwc_GetSoundCards@files:get_hw_caps.dll stdcall';
 
function GetSystemPage(): Integer;
external 'hwc_GetSystemPage@files:get_hw_caps.dll stdcall';
 
function GetSystemPhys(): Integer;
external 'hwc_GetSystemPhys@files:get_hw_caps.dll stdcall';
 
function GetVidMemLocal(): Integer;
external 'hwc_GetVidMemLocal@files:get_hw_caps.dll stdcall';
 
function GetVidMemNonLocal(): Integer;
external 'hwc_GetVidMemNonLocal@files:get_hw_caps.dll stdcall';
 
function GetVideoCardDev(): Integer;
external 'hwc_GetVideoCardDev@files:get_hw_caps.dll stdcall';
 
function GetVideoCardVen(): Integer;
external 'hwc_GetVideoCardVen@files:get_hw_caps.dll stdcall';
 
function  DelSp(const s:string):string;// функция удаления пробелов в начале строки
var
  c, i: integer;
  stt, st, st1: string;
begin
  c := 0;
  st := s;
 
  for i := 1 to Length(st) do
  begin
 
    stt := copy(st, i, 1);
    if (stt = ' ') and (c >= 1) then
    begin
      st1 := st1;
      c := c + 1;
    end
    else if (stt = ' ') and (c = 0) then
    begin
      c := c + 1;
      st1 := st1 + stt;
    end
    else if (stt <> ' ') then
    begin
      c := 0;
      st1 := st1 + stt;
    end
  end;
 
  Result:= st1;
end;
 
function CheckSystemPage(PreviousPageId: Integer): Integer;
var Page: TWizardPage;
    ProcessorName:string;
    Processor,VideoCardPanel,AudioCardPanel,RAMPanel,PageFilePanel: TPanel;
    ProcessorNamePanel,VideoCardNamePanel,AudioCardNamePanel,RAMTotalPanel,PageFileTotalPanel: TPanel;
    ProcessorMHZ: Cardinal;
    StaticText,StaticText2:TNewStaticText;
    VidRam:integer;
begin
RegQueryStringValue(HKLM, 'HARDWARE/DESCRIPTION/System/CentralProcessor/0','ProcessorNameString', ProcessorName);
RegQueryDWordValue(HKLM, 'HARDWARE/DESCRIPTION/System/CentralProcessor/0','~MHz', ProcessorMHZ);
GetVidMemLocal;
GetSoundCards;
 
Page := CreateCustomPage(PreviousPageId,'Апаратное Обеспечение','Программа установки обнаружила следуюшие необходимые компоненты');
 
StaticText:=TNewStaticText.Create(Page);
with StaticText do
begin
Parent:=Page.Surface;
Caption:='Все компоненты удовлетворяют требованиям игры.';
Left:=0;
Top:=5;
AutoSize:=True;
end;
 
StaticText2:=TNewStaticText.Create(Page);
with StaticText2 do
begin
Parent:=Page.Surface;
Caption:='Когда будете готовы продолжить установку, нажмите Далее'
Left:=0;
Top:=220;
AutoSize:=True;
end;
 
Processor := TPanel.Create(Page);
with Processor do
begin
Parent := Page.Surface;
Caption := ' Процессор';
Left := ScaleX(0);
Top := ScaleY(32);
alignment:=taLeftJustify;
Width := ScaleX(121);
Height := ScaleY(25);
BevelInner := bvLowered;
TabOrder := 0;
end;
 
ProcessorNamePanel := TPanel.Create(Page);
with ProcessorNamePanel do
begin
Parent := Page.Surface;
Caption :=DelSP(ProcessorName)+'  '+IntToStr(ProcessorMHZ)+'MHz' ;  //новое обработанное значение строки
// Caption :=ProcessorName+'  '+IntToStr(ProcessorMHZ)+'MHz' ;
Left := ScaleX(128);
Top := ScaleY(32);
alignment:=taLeftJustify;
Width := ScaleX(281);
Height := ScaleY(25);
BevelInner := bvLowered;
Color :=$ccffcc;
TabOrder := 1;
end;
 
if ProcessorMHZ<1800then
begin
ProcessorNamePanel.Color:=clRed;
StaticText.Caption:='Не все компоненты удовлетворяют требованиям игры.';
end;
 
VideoCardPanel:=TPanel.Create(Page);
with VideoCardPanel do
begin
Parent:=Page.Surface;
Caption:=' Видеоадаптер';
Left:=ScaleX(0);
alignment:=taLeftJustify;
Top:=Processor.Top+27;
Width:=ScaleX(121);
Height:=ScaleY(25);
BevelInner:=bvLowered;
TabOrder:=0;
end;
 
VideoCardNamePanel:=TPanel.Create(Page);
with VideoCardNamePanel do
begin
Parent:=Page.Surface;
Caption:=' '+GetVideoCardName; //+'    ОЗУ-'+inttostr(round(GetVidMemLocal/1000000))+' МБ';
//Caption:='    ОЗУ-'+inttostr(GetVidMemLocal)+' МБ';
VidrAM:= GetVidMemLocal/1000000;
 
if VidRam>127 then
 begin
  if VidRam<200 then  Caption:=Caption+' 128 МB'
  else if VidRam<300 then  Caption:=Caption+' 256 МB'
    else if VidRam<400 then  Caption:=Caption+' 384 МB'
      else if  VidRam>500 then  Caption:=Caption+' 512 МB';
 end;
 
Left:=ScaleX(128);
Top:=VideoCardPanel.Top;
alignment:=taLeftJustify;
Width:=ScaleX(281);
Height:=ScaleY(25);
BevelInner:=bvLowered;
Color :=$ccffcc;
TabOrder:=1;
end;
 
if GetVidMemLocal<127000000 then //128MB
begin
StaticText.Caption:='Не все компоненты удовлетворяют требованиям игры.';
VideoCardNamePanel.Color:=clRed;
end;
 
AudioCardPanel:=TPanel.Create(Page);
with AudioCardPanel do
begin
Parent:=Page.Surface;
Caption:=' Звуковая карта';
Left:=ScaleX(0);
Top:=VideoCardPanel.Top+27;
alignment:=taLeftJustify;
Width:=ScaleX(121);
Height:=ScaleY(25);
BevelInner:=bvLowered;
TabOrder:=0;
end;
 
AudioCardNamePanel:=TPanel.Create(Page);
with AudioCardNamePanel do
begin
Parent:=Page.Surface;
Caption:=' '+GetSoundCardName;
Left:=ScaleX(128);
alignment:=taLeftJustify;
Top:=AudioCardPanel.Top;
Width:=ScaleX(281);
Height:=ScaleY(25);
BevelInner:=bvLowered;
TabOrder:=1;
Color :=$ccffcc;
end;
 
if
GetSoundCards=0 then
begin
StaticText.Caption:='Не все компоненты удовлетворяют требованиям игры.';
AudioCardNamePanel.Color:=clRed;
end;
 
 
RAMPanel:=TPanel.Create(Page);
with RAMPanel do
begin
Parent:=Page.Surface;
Caption:=' ОЗУ'
Left:=0;
Top:=AudioCardPanel.Top+27;
alignment:=taLeftJustify;
Width:=ScaleX(121);
Height:=ScaleY(25);
BevelInner:=bvLowered;
TabOrder:=0;
end;
 
RAMTotalPanel:=TPanel.Create(Page);
with RAMTotalPanel do
begin
Parent:=Page.Surface;
Caption:=' '+IntToStr(GetSystemPhys+1) +' MB'
Left:=AudioCardNamePanel.Left;
Top:=RAMPanel.Top;
alignment:=taLeftJustify;
Width:=AudioCardNamePanel.Width;
Height:=ScaleY(25);
BevelInner:=bvLowered;
TabOrder:=1;
Color :=$ccffcc;
end;
 
if GetSystemPhys+1<1024 then
begin
RAMTotalPanel.Color:=clRed;
StaticText.Caption:='Не все компоненты удовлетворяют требованиям игры.';
end;
 
PageFilePanel:=TPanel.Create(Page);
with PageFilePanel do
begin
Parent:=Page.Surface;
Caption:=' Файл подкачки';
alignment:=taLeftJustify;
Left:=0;
Top:=RAMPanel.Top+27;
Width:=RAMPanel.Width;
Height:=ScaleY(25);
BevelInner:=bvLowered;
TabOrder:=0;
end;
 
PageFileTotalPanel:=TPanel.Create(Page);
with PageFileTotalPanel do
begin
Parent:=Page.Surface;
Caption:=' '+IntToStr(GetSystemPage)+' MB';
Left:=RAMTotalPanel.Left;
Top:=PageFilePanel.Top;
alignment:=taLeftJustify;
Width:=RAMTotalPanel.Width;
Height:=ScaleY(25);
BevelInner:=bvLowered;
TabOrder:=1;
Color :=$ccffcc;
end;
 
if GetSystemPage<1247 then
begin
PageFileTotalPanel.Color:=clRed;
StaticText.Caption:='Не все компоненты удовлетворяют требованиям игры.';
end;
 
Result := Page.ID;
end;
//////////////////
 
//////Сплэш-скрин
var
Splash: TSetupForm;
 
var
mp3Handle: HWND;
mp3Name: string;
PlayButton : TButton;
PauseButton : TButton;
StopButton : TButton;
Panel1: TPanel;
 
////////////Функции MP3 + Кнопки
function BASS_Init(device: Integer; freq, flags: DWORD; win: hwnd; CLSID: Integer): Boolean;
external 'BASS_Init@files:BASS.dll stdcall delayload';
 
function BASS_StreamCreateFile(mem: BOOL; f: PChar; offset: DWORD; length: DWORD; flags: DWORD): DWORD;
external 'BASS_StreamCreateFile@files:BASS.dll stdcall delayload';
 
function BASS_Start(): Boolean;
external 'BASS_Start@files:BASS.dll stdcall delayload';
 
function BASS_ChannelPlay(handle: DWORD; restart: BOOL): Boolean;
external 'BASS_ChannelPlay@files:BASS.dll stdcall delayload';
 
function BASS_ChannelIsActive(handle: DWORD): Integer;
external 'BASS_ChannelIsActive@files:BASS.dll stdcall delayload';
 
function BASS_ChannelPause(handle: DWORD): Boolean;
external 'BASS_ChannelPause@files:BASS.dll stdcall delayload';
 
function BASS_Stop(): Boolean;
external 'BASS_Stop@files:BASS.dll stdcall delayload';
 
function BASS_Pause(): Boolean;
external 'BASS_Pause@files:BASS.dll stdcall delayload';
 
function BASS_Free(): Boolean;
external 'BASS_Free@files:BASS.dll stdcall delayload';
 
procedure PauseButtonOnClick(Sender: TObject);
begin
BASS_ChannelPause(mp3Handle);
end;
 
 
procedure StopButtonOnClick(Sender: TObject);
begin
BASS_Stop();
BASS_Free();
end;
 
 
const
BASS_ACTIVE_STOPPED = 0;
BASS_ACTIVE_PLAYING = 1;
BASS_ACTIVE_STALLED = 2;
BASS_ACTIVE_PAUSED = 3;
BASS_SAMPLE_LOOP = 4;
 
function InitializeSetup(): Boolean;
var
  BitmapImage1: TBitmapImage;
  ResultCode: Integer;
  MD5,ResultStr:string;
  hWnd: Integer;
begin
ExtractTemporaryFile('BASS.dll');
ExtractTemporaryFile('sound.mp3');
mp3Name := ExpandConstant('{tmp}/sound.mp3');
BASS_Init(-1, 44100, 0, 0, 0);
mp3Handle := BASS_StreamCreateFile(FALSE, PChar(mp3Name), 0, 0, BASS_SAMPLE_LOOP);
BASS_Start();
BASS_ChannelPlay(mp3Handle, False);
Result := True;
 
begin
  Splash := CreateCustomForm;
  Splash.BorderStyle := bsNone;
  BitmapImage1 := TBitmapImage.Create(Splash);
  with BitmapImage1 do begin
    AutoSize := True;
    Align := alClient;
    Left := 0;
    Top := 0;
    Stretch := True;
    Parent := Splash;
  end;
  ExtractTemporaryFile('Splash.bmp');
  BitmapImage1.Bitmap.LoadFromFile(ExpandConstant('{tmp}') + '/Splash.bmp');
  Splash.Width := BitmapImage1.Width;
  Splash.Height := BitmapImage1.Height;
  Splash.Center;
  Splash.Show;
  BitmapImage1.Refresh;
  Sleep(2000); //Время показа (здесь 3 секунды)
  Result := True;
  
////////////Функции MP3 + Кнопки
end;
begin
Result:=True;
///////////Проверка электронной подписи
if not FileExists(ExpandConstant('{src}')+'/website.url') then
  begin
   MsgBox('Электронная подпись не найдена.'#13#13'Вы используете взломанную или пиратскую версию.', mbError, mb_OK);
    Result:= False;
  end
  else
begin
  MD5 := GetMD5OfFile(ExpandConstant('{src}/website.url'));
  If not (MD5 = '2b5db4b3d57755af4891cd5a53902f48') then
 begin
    MsgBox('Произошла критическая ошибка!'#13'Электронная подпись повреждена.'#13'Обратитесь к разработчику!', mbCriticalError, mb_OK);
     Result:=False;
end;
end;
end;
end;
////////////////////////
////////////////////////
procedure PlayButtonOnClick(Sender: TObject);
begin
case BASS_ChannelIsActive(mp3Handle) of
BASS_ACTIVE_PAUSED:
begin
BASS_ChannelPlay(mp3Handle, False);
end;
BASS_ACTIVE_STOPPED:
begin
BASS_Init(-1, 44100, 0, 0, 0);
mp3Handle := BASS_StreamCreateFile(FALSE, PChar(mp3Name), 0, 0, BASS_SAMPLE_LOOP);
BASS_Start();
BASS_ChannelPlay(mp3Handle, False);
end;
end;
end;
 
 
procedure DirOnClick(Sender: TObject);
var
  res: Boolean;
  UserSelectDir: string;
begin
  UserSelectDir := WizardForm.DirEdit.Text;
  res := BrowseForFolder('Выберите директорию для установки и нажмите ''ОК''', UserSelectDir, True);
  if res then
  begin
    WizardForm.DirEdit.Text := UserSelectDir;
  end;
end;
 
 
 
 
 
 
////////////////////////
 
 
/////////Функции слайд-шоу
const
  BACKGROUND = 6; // "5"-по центру, "6"-растянуто на весь экран, "1,2,3,4"-в разных углах экрана
  TIMER = 16;
 
function isxbb_AddImage(Image: PChar; Flags: Cardinal): Integer;
  external 'isxbb_AddImage@files:isxbb.dll stdcall';
function isxbb_Init(hWnd: Integer): Integer;
  external 'isxbb_Init@files:isxbb.dll stdcall';
function isxbb_StartTimer(Seconds: Integer; Flags: Cardinal): Integer;
  external 'isxbb_StartTimer@files:isxbb.dll stdcall';
function isxbb_KillTimer(Flags: Cardinal): Integer;
  external 'isxbb_KillTimer@files:isxbb.dll stdcall';
function GetSystemMetrics(nIndex: Integer): Integer;
  external 'GetSystemMetrics@user32.dll stdcall';
///////////////////////////
 
//////////////Нажатия на Beveled
procedure BevelLabelOnClick(Sender: TObject);
var
ErrorCode: Integer;
begin
ShellExec('open', 'http://www.chuvakstepan.xost.ru', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;
///////////////////////////
 
/////// Фоновый рисунок
procedure InitializeWizard();
var
  BackgroundBitmapImage: TBitmapImage;
  s: string;
  License: string;
  ResultCode_1: Integer;
  width, height: Integer;
  SplashImage: TBitmapImage;
  SplashForm: TForm;
  SplashFileName: String;
  I : Integer;
  b : string;
  Name1: string;
  PlayButton, PauseButton, StopButton: TButton;
  Text: TNewStaticText;
  Panel1: TPanel;
  License: String;
  Path: String;
  FreeMB, TotalMB: Cardinal;
  drives: DWORD;
begin
  WizardForm.Position := poScreenCenter;
  WizardForm.DirBrowseButton.OnClick := @DirOnClick;
  MainForm.BORDERSTYLE := bsNone;
  //2000-скорость, AW_DIAG_SLIDE_IN_BOTTOMRIGHT - эффект
  //AnimateWindow(WizardForm.Handle, 500, AW_SLIDE_IN_BOTTOM);
  WizardForm.CancelButton.BringToFront;
  width := GetSystemMetrics(0);
  height := GetSystemMetrics(1);
  MainForm.Width := width;
  MainForm.Height := height;
  width := MainForm.ClientWidth;
  height := MainForm.ClientHeight;
  ExtractTemporaryFile('Background.bmp');
  s := ExpandConstant('{tmp}') + '/Background.bmp';
  BackgroundBitmapImage := TBitmapImage.Create(MainForm);
  BackgroundBitmapImage.Bitmap.LoadFromFile(s);
  BackgroundBitmapImage.Left := 0;
  BackgroundBitmapImage.Top := 0;
  BackgroundBitmapImage.Width := width;
  BackgroundBitmapImage.Height := height;
  BackgroundBitmapImage.Parent := MainForm;
  BackgroundBitmapImage.Stretch := True;
  CheckSystemPage(wpLicense);
  MainForm.Visible := True;
  
////////////Сплэш-скрин
 
 
/////////Большые картинки (1-ая WizardImageFile, 2-ая тут)
begin
ExtractTemporaryFile('st_fin.bmp')
b:=ExpandConstant('{tmp}/st_fin.bmp')
with WizardForm do
begin
WizardBitmapImage.Width:=WizardForm.ClientWidth;
WelcomeLabel1.Visible:=False;
WelcomeLabel2.Visible:=False;
WizardBitmapImage2.Bitmap.LoadFromFile(b);
WizardBitmapImage2.Width:=WizardForm.ClientWidth;
FinishedLabel.Visible:=False;
FinishedHeadingLabel.Visible:=False;
end;
end;
///////////////////Маленькая картинка становиться щире
begin
  with WizardForm do begin
    with MainPanel do
      Height := Height - 0;
    with WizardSmallBitmapImage do begin
      Left := 0; //значение 0 - слева, 347 - справа
      Top := 0;
      Height := 58; //Размер рисунка
      Width := 495; //
    end;
    with PageNameLabel do begin
      Width := Width - 1; //Поставьте здесь значения на 0 если хотите вернуть текст
      Visible:= False
      Left := Left + 0; //
    end;
    with PageDescriptionLabel do begin
      Width := Width - 80; //Поставьте здесь значения на 0 если хотите вернуть текст
      Visible:= False
      Left := Left + 0; //
    end;
  end;
end
begin
  Splash.Close;
end;
///////////////Действия, при нажатии на Beveled
begin
  with WizardForm.BeveledLabel do
  begin
    Cursor := crHand; //Вид курсора при наведении на текст
    OnClick := @BevelLabelOnClick;
    Font.Style := Font.Style + [fsUnderline];
    Font.Color := clMaroon; //Цвет текста
    Enabled := True;
  end;
end;
//////////////////Музыка
begin
WizardForm.Position := poScreenCenter;
WizardForm.CancelButton.BringToFront;
begin
Panel1 := TPanel.Create(WizardForm);
with Panel1 do
begin
 
 
PlayButton := TButton.Create(WizardForm);
PlayButton.Left := 10;
PlayButton.Top := WizardForm.ClientHeight - ScaleY(23 + 10);
PlayButton.Width := 30;
PlayButton.Caption := '>';
PlayButton.OnClick := @PlayButtonOnClick;
PlayButton.Parent := WizardForm;
PlayButton.Cursor := crHand;
PauseButton := TButton.Create(WizardForm);
PauseButton.Left := 45;
PauseButton.Top := WizardForm.ClientHeight - ScaleY(23 + 10);
PauseButton.Width:=30;
PauseButton.Caption := 'II';
PauseButton.OnClick := @PauseButtonOnClick;
PauseButton.Parent := WizardForm;
PauseButton.Cursor := crHand;
StopButton := TButton.Create(WizardForm);
StopButton.Left := 80;
StopButton.Top := WizardForm.ClientHeight - ScaleY(23 + 10);
StopButton.Width := 30;
StopButton.Caption := '[]';
StopButton.OnClick := @StopButtonOnClick;
StopButton.Parent := WizardForm;
StopButton.Cursor := crHand;
 
 
end;
end;
end;
ExtractTemporaryFile('License.rtf');
LoadStringFromFile(ExpandConstant('{tmp}') + '/License.rtf', License)
WizardForm.LicenseMemo.RTFText := License;
ListBox:= TListBox.Create(WizardForm);
  ListBox.Top:= 120;
  ListBox.Width:= 300;
  ListBox.Height:= ScaleY(90);
  ListBox.Parent:= WizardForm.SelectDirPage;
  ListBox.OnClick:= @ListBoxOnClick;
 
  drives:= GetLogicalDrives();
  for i:= 0 to 31 do
     begin
        if (drives and (1 shl i)) > 0 then
            begin
              Path:= chr(ord('A')+i)+':';
              if GetDriveType(Path) = DRIVE_FIXED then
                begin
                  GetSpaceOnDisk(Path, True, FreeMB, TotalMB);
                  ListBox.Items.Add(Path + ' Свободно: ' + IntToStr(FreeMB) + 'Мб');
                end;
end;
end;
end;
 
 
////////////////////////////
////////////////////////////
////////////////////////////
////////////////////////////
 
////////Процедура слайд-шоу
procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep = ssInstall
    then
  begin
    ExtractTemporaryFile('1.jpg'); // это файлы для слайд-шоу, их может быть и больше
    ExtractTemporaryFile('2.jpg');
    ExtractTemporaryFile('3.jpg');
    ExtractTemporaryFile('4.jpg');
    ExtractTemporaryFile('5.jpg');
    ExtractTemporaryFile('6.jpg');
    ExtractTemporaryFile('7.jpg');
    ExtractTemporaryFile('8.jpg');
    ExtractTemporaryFile('9.jpg');
    isxbb_AddImage(ExpandConstant('{tmp}') + '/1.jpg', BACKGROUND or TIMER);
    isxbb_AddImage(ExpandConstant('{tmp}') + '/2.jpg', BACKGROUND or TIMER);
    isxbb_AddImage(ExpandConstant('{tmp}') + '/3.jpg', BACKGROUND or TIMER);
    isxbb_AddImage(ExpandConstant('{tmp}') + '/4.jpg', BACKGROUND or TIMER);
    isxbb_AddImage(ExpandConstant('{tmp}') + '/5.jpg', BACKGROUND or TIMER);
    isxbb_AddImage(ExpandConstant('{tmp}') + '/6.jpg', BACKGROUND or TIMER);
    isxbb_AddImage(ExpandConstant('{tmp}') + '/7.jpg', BACKGROUND or TIMER);
    isxbb_AddImage(ExpandConstant('{tmp}') + '/8.jpg', BACKGROUND or TIMER);
    isxbb_AddImage(ExpandConstant('{tmp}') + '/9.jpg', BACKGROUND or TIMER);
    isxbb_Init(StrToInt(ExpandConstant('{hwnd}')));
    isxbb_StartTimer(10, BACKGROUND) // это таймер для слайд-шоу в секундах
  end
  else if CurStep = ssPostInstall then
    isxbb_KillTimer(BACKGROUND);
end;
////////////////////////
 
 
procedure DeinitializeSetup();
begin
BASS_Stop();
BASS_Free();
end;
 
 
 
//////////////////////Изменение окна установки вместе с кнопками управления музыкой
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID=1 then
 begin
  If WizardForm.FindComponent('NextButton') is TButton
 then
  TButton(WizardForm.FindComponent('NextButton')).Caption:='Начать Установку >>>';
  TButton(WizardForm.FindComponent('NextButton')).Width:=ScaleX(135);
  WizardForm.NextButton.Left:=WizardForm.ClientWidth - ScaleX(217 + 10);  //Отступ слева кнопки: Отмена.
  WizardForm.NextButton.Top:=WizardForm.ClientHeight - ScaleY(23 + 10); //Отступ сверху кнопки: Отмена.
  WizardForm.BackButton.Left:=WizardForm.ClientWidth - ScaleX(300 + 10);  //Отступ слева кнопки: Отмена.
  WizardForm.BackButton.Top:=WizardForm.ClientHeight - ScaleY(23 + 10); //Отступ сверху кнопки: Отмена.
  If WizardForm.FindComponent('CancelButton') is TButton
then
  TButton(WizardForm.FindComponent('CancelButton')).Caption:='Выход';
end;
begin
if CurPageID=wpInstalling
then
begin
WizardForm.MainPanel.Visible:=False;
WizardForm.Bevel1.Visible:=False;
WizardForm.Width:=ScaleX(395);
WizardForm.Height:=ScaleY(142);
WizardForm.Left:=ScaleX(MainForm.Width-420);
WizardForm.Top:=ScaleY(MainForm.Height-170);
WizardForm.InnerNotebook.Left:=ScaleX(10);
WizardForm.InnerNotebook.Top:=ScaleY(10);
WizardForm.InnerNotebook.Width:=ScaleX(370);
WizardForm.StatusLabel.Left:=ScaleX(0);
WizardForm.StatusLabel.Top:=ScaleY(0);
WizardForm.StatusLabel.Width:=WizardForm.InnerNotebook.Width;
WizardForm.FileNameLabel.Left:=ScaleX(0);
WizardForm.FileNameLabel.Top:=ScaleY(20);
WizardForm.FileNameLabel.Width:=WizardForm.InnerNotebook.Width;
WizardForm.ProgressGauge.Top:=ScaleY(40);
WizardForm.ProgressGauge.Width:=WizardForm.InnerNotebook.Width;
WizardForm.CancelButton.Left:=ScaleX(154);
WizardForm.CancelButton.Top:=ScaleY(80);
 
PlayButton := TButton.Create(WizardForm);
PlayButton.Left := 10;
PlayButton.Top := WizardForm.ClientHeight - ScaleY(23 + 10);
PlayButton.Width := 30;
PlayButton.Caption := '>';
PlayButton.OnClick := @PlayButtonOnClick;
PlayButton.Parent := WizardForm;
PlayButton.Cursor := crHand;
PauseButton := TButton.Create(WizardForm);
PauseButton.Left := 45;
PauseButton.Top := WizardForm.ClientHeight - ScaleY(23 + 10);
PauseButton.Width:=30;
PauseButton.Caption := 'II';
PauseButton.OnClick := @PauseButtonOnClick;
PauseButton.Parent := WizardForm;
PauseButton.Cursor := crHand;
StopButton := TButton.Create(WizardForm);
StopButton.Left := 80;
StopButton.Top := WizardForm.ClientHeight - ScaleY(23 + 10);
StopButton.Width := 30;
StopButton.Caption := '[]';
StopButton.OnClick := @StopButtonOnClick;
StopButton.Parent := WizardForm;
StopButton.Cursor := crHand;
end
if CurPageID=wpFinished
then
begin
WizardForm.Width:=502;
WizardForm.Height:=392;
WizardForm.Position:=poScreenCenter;
PlayButton.Visible := False;
PauseButton.Visible := False;
StopButton.Visible := False;
end;
end;
end;
 
////////////////////////////////////////////
 
///////////Запрос на выход из установки....
const
MB_ICONINFORMATION = $40;
MB_ICONEXCLAMATION = $30;
MB_ICONQUESTION = $20;    
MB_ICONSTOP = $10;
MB_ICONNONE = $0;
 
function MessageBox(hWnd: Integer; lpText, lpCaption: String; uType: Cardinal): Integer;
external 'MessageBoxA@user32.dll stdcall';
 
procedure CancelButtonClick(CurPage: Integer; var Cancel, Confirm: Boolean);
 var
 hWnd: Integer;
begin
Cancel:=False;
Confirm:=False;
hWnd := StrToInt(ExpandConstant('{wizardhwnd}'));
  if MessageBox(hWnd, 'Вы действительно хотите отменить установку игры?', 'Выход из установки', MB_YESNO or $0) = idYes
 then
  Cancel:=true;
end;  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值