PDA

Показать полную графическую версию : Скрипты Inno Setup. Помощь и советы [часть 3]


Страниц : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 [35] 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188

duxa
31-01-2011, 20:01
Vamp1re, precomp.exe *команда* *сам файл*
Список команд:


r "Recompress" PCF file (restore original file)
o[filename] Write output to [filename] <[input_file].pcf or file in header>
f Fast mode, use first found compression lvl for all streams <off>
c[1..9] Compression levels to try for compression <123456789>
m[1..9] Memory levels to try for compression <123456789>
i[pos] Ignore stream at input file position [pos] <none>
s[size] Set minimal identical byte size to [size] <4 (64 in slow mode)>
slow Detect raw zLib headers, too. Slower and more sensitive <off>
brute Brute force zLib detection. VERY Slow and most sensitive <off>
pdfbmp[+-] Wrap a BMP header around PDF images <off>
progonly[+-] Recompress progressive JPGs only (useful for PAQ) <off>
v Verbose (debug) mode <off>

t[+-][pzgnfj] Compression type switch <all enabled>
t+ enables certain compression types and disables the other ones
t- disables certain compression types and enables the other ones
P = PDF, Z = ZIP, G = GZip, N = PNG, F = GIF, J = JPG, S = SWF

Vamp1re
31-01-2011, 20:13
duxa, А ничего прописывать в разделе [code] ненадо?

Gnom_aka_Lexander
31-01-2011, 20:24
Vamp1re, простейший вариант - пишеш в батник, и запускаеш его из секции[RUN]
А чтоб красиво - через исдоне.

Vamp1re
31-01-2011, 20:28
у меня еще один вопрос: как сжать папку с файлами через precomp? :)

Gnom_aka_Lexander
31-01-2011, 20:40
Vamp1re, я недавно (http://forum.oszone.net/post-1590739-572.html) давал русскую справку по прекомпу, довольно подробную.
То, что тебе нужно - команда пакетной обработки. И да, способы сжатия в этой теме - оффтоп.

Gnom_aka_Lexander
01-02-2011, 10:07
Neutron, Давай проще, расскажи, чего хочеш, почти наверняка то, что ты хочеш уже есть :)

zark
01-02-2011, 13:27
У меня есть 32-битное приложение. Также есть DLL, которая реализует расширение контекстного меню проводника. Для win32 32-бтная библиотека, а для win64 - 64 - битная. Возник вопрос - как создать единый инсталлятор? Т.е. чтобы инсталлятор сам понимал какой файл библотеки ему брать и регистрировать в системе.
Что-то типа:

[Files]
...
if <ОС 32 битная> then
Source: "allfiles\ACMenu.dll"; DestDir: "{app}"; Flags: 32bit noregerror regserver restartreplace;
else
Source: "allfiles\ACMenu64.dll"; DestDir: "{app}"; Flags: 64bit noregerror regserver restartreplace;
endif;

Можно ли это реализовать средствами InnoSetup?

Gnom_aka_Lexander
01-02-2011, 13:32
zark,
[Files]
Source: "allfiles\ACMenu.dll"; DestDir: "{app}"; chek: not isWin64; Flags: 32bit noregerror regserver restartreplace;
Source: "allfiles\ACMenu64.dll"; DestDir: "{app}";chek: isWin64; Flags: 64bit noregerror regserver restartreplace;

R.i.m.s.k.y.
01-02-2011, 14:05
zark, Лександер, верно но нужно дописать в
[Setup]
ArchitecturesInstallIn64BitMode=x64

и не Chek а Check
[Files]
Source: "allfiles\ACMenu.dll"; DestDir: "{app}"; Check: (not isWin64); Flags: 32bit noregerror regserver restartreplace;
Source: "allfiles\ACMenu64.dll"; DestDir: "{app}";Check: (isWin64); Flags: 64bit noregerror regserver restartreplace;

Gnom_aka_Lexander
01-02-2011, 15:47
R.i.m.s.k.y., не, эта строчка обозначает архитектуру приложения, и если ее дописать, то 32-х битное приложение на 64-х битной винде установится не в Program Files (x86), как должно-бы, а в Program Files, изза чего глюки с *открыть с помощью...* возникают, ну может еще какие, в общем, если приложение не х64, то эту строчку писать нельзя.
А вот флаги 32bit и 64bit можно не ставить при Check: (isWin64) и Check: (not isWin64). :)

R.i.m.s.k.y.
01-02-2011, 15:50
изза чего глюки с *открыть с помощью...* возникают »
глюки не возникнут если правильно прописывать пути, вообще не столкнулся с такой проблемой.
не, эта строчка обозначает архитектуру приложения »
Specifies the 64-bit processor architecture(s) on which Setup should install in 64-bit mode. If this directive is not specified or is blank, Setup will always install in 32-bit mode.
Normally, you should not change this directive from its default value unless your application contains native 64-bit binaries.

Без этой строчки в ос64 его файлики64 не зарегятся тк Setup will always install in 32-bit mode
Ну и следствие отсутствия этой строчки - да, предлагает по-умолчанию Program Files (x86)

Там еще в помощи важное примечание: Be sure you have read the 64-bit Installation Limitations topic before setting this directive


Because Inno Setup is a 32-bit application, there are some limitations to be aware of when utilizing its 64-bit installation features:

The System32 path returned by the {sys} constant does not always map to the 64-bit System directory. When Setup/Uninstall is running in 64-bit mode, it maps to the 64-bit System directory when used in the [Dirs], [Files], [InstallDelete], [Run], [UninstallDelete], and [UninstallRun] sections because Setup temporarily disables WOW64 file system redirection when files/directories are accessed by those sections. Elsewhere, System32 and {sys} map to the 32-bit System directory, as is normal in a 32-bit process.
In the [_Code] section, when Setup/Uninstall is running in 64-bit mode, functions that access files disable WOW64 file system redirection (unless overridden by a call to EnableFsRedirection). However, there are exceptions, listed below. These functions never disable file system redirection, meaning you cannot pass them (or get back) the name of a file located in the 64-bit System directory:

*Ini* (all of the functions that manipulate .INI files)
BrowseForFolder
CreateShellLink
GetOpenFileName
LoadDLL (see following point)
ModifyPifFile
SetCurrentDir
ShellExec (use Exec instead)
UnregisterFont

Additionally, no VCL classes are capable of disabling file system redirection. For example, you cannot call the LoadFromFile method of TBitmap to load a bitmap file from the 64-bit System directory.

You cannot load/use 64-bit DLLs in the [_Code] section, because Windows does not allow 32-bit processes to load 64-bit DLLs (and vice versa). A 32-bit process can, however, launch 64-bit EXEs. Use the Exec function or the [Run] section to do that.

Also, there is one limitation of the compiler:

You cannot compile a script that includes 64-bit binaries on Windows 95, 98, Me, or NT 4.0, because those versions of Windows do not support reading version info on 64-bit images.


А вот флаги 32bit и 64bit »
их НУЖНО ставить, нажми F1 и почитай
32bit
Causes the {sys} constant to map to the 32-bit System directory when used in the Source and DestDir parameters, the regserver and regtypelib flags to treat the file as 32-bit, and the sharedfile flag to update the 32-bit SharedDLLs registry key. This is the default behavior in a 32-bit mode install.

64bit
Causes the {sys} constant to map to the 64-bit System directory when used in the Source and DestDir parameters, the regserver and regtypelib flags to treat the file as 64-bit, and the sharedfile flag to update the 64-bit SharedDLLs registry key. This is the default behavior in a 64-bit mode install.

Gnom_aka_Lexander
01-02-2011, 16:05
R.i.m.s.k.y., Я нерусских языков не понимаю :) , потому нерусской справкой пользоваться не в состоянии :)
Поэтому просто поверю тебе на слово :).

R.i.m.s.k.y.
01-02-2011, 16:27
Лександер, а в русской не написано? мне переводить вломмм. Просто скажу - в ос64 для файликов64 пользуем флаг64, и очень аккуратно чтобы не напутать. Папка System32 - для файликов64, Syswow64 - для файликов32, ключи реестра к примеру HKLM64 (так и пишется!).
Кодеки32 начинают писаться в HKLM\SOFTWARE\Wow6432Node\Classes\CLSID\... и HKLM\SOFTWARE\Classes\Wow6432Node\CLSID\... вместо HKLM\SOFTWARE\Classes\CLSID\...

Habetdin
02-02-2011, 01:59
Neutron, но выдаёт сообщение: function InitializeSetup:boolean;! »
Может dublicate в конце? ;)
Скрипт:
[Setup]
AppId={{467F7BE6-FAAD-4ABF-A5E1-980896892382}
AppName=My Program
AppVersion=1.5
AppVerName=My Program
AppPublisher=My Company, Inc.
AppPublisherURL=http://www.example.com/
AppSupportURL=http://www.example.com/
AppUpdatesURL=http://www.example.com/
DefaultDirName={code:NoSD}\Games\My Program
DefaultGroupName=My Program
AllowNoIcons=yes
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
OutputDir=.

[Languages]
Name: russian; MessagesFile: compiler:Languages\Russian.isl

[Tasks]
Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}

[Files]
;Source: C:\Rus\*; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs
Source: Data\ISSkin.dll; DestDir: {tmp}; Flags: ignoreversion dontcopy nocompression
Source: Data\tiger_v2.cjstyles; DestDir: {tmp}; Flags: ignoreversion dontcopy nocompression
Source: Data\bass.dll; DestDir: {tmp}; Flags: ignoreversion dontcopy nocompression
Source: Data\innocallback.dll; DestDir: {tmp}; Flags: ignoreversion dontcopy nocompression
Source: Data\Play.mp3; DestDir: {tmp}; Flags: ignoreversion dontcopy nocompression

[Icons]
Name: {group}\My Program; Filename: {app}\MyProg.exe
Name: {group}\{cm:UninstallProgram,My Program}; Filename: {uninstallexe}
Name: {commondesktop}\My Program; Filename: {app}\MyProg.exe; Tasks: desktopicon

[Run]
Filename: {app}\MyProg.exe; Description: {cm:LaunchProgram,My Program}; Flags: nowait postinstall skipifsilent unchecked


[Code]
//WizardForm.Bevel.visible:=true;
//WizardForm.Bevel1.visible:=true;
//WizardForm.Font.Color:=clWhite;

//-------------------- Автовыбор диска установки - Начало --------------------\\
function GetLogicalDrives: DWORD; external 'GetLogicalDrives@kernel32.dll stdcall';
function GetDriveType(lpRootPathName: PChar): Cardinal; external 'GetDriveTypeA@kernel32.dll stdcall';

const
DRIVE_FIXED = 3;

function NoSD(s: string): string;
var
x, bit, i: Integer;
tp: Cardinal;
sd: string;
begin
sd:= ExpandConstant('{sd}');
Result:= sd;
// Вызываем функцию WinAPI
// Функция возвращает битовую маску установленных логических дисков.
// Бит 0 определяет наличие диска А:, бит 1 - диска B и т.д.
x:= GetLogicalDrives;
if x <> 0 then
// Цикл по полученным битам переменной X
for i:= 1 to 64 do
begin
// Накладываем битовую маску для выделения бита с поряковым номером 0
bit:= x and 1;
// Нашли логический диск...
if bit = 1 then
begin
// Определяем тип логического диска
tp:= GetDriveType(PChar(Chr(64 + i) + ':'));
if tp = DRIVE_FIXED then
// Если диск не является системным
if Chr(64 + i) <> Copy(sd, 1, 1) then
begin
Result:= Chr(64 + i) + ':';
Break;
end;
end;
// Побитовый сдвиг вправо
x:= x shr 1;
end;
end;
//-------------------- Автовыбор диска установки - Конец --------------------\\

//-------------------- Поиск приложений через реестр - Начало --------------------\\
var
ResultStr:string;
ResultCode: Integer;

function InitializeSetup1(): Boolean;
begin
RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{467F7BE6-FAAD-4ABF-A5E1-980896892382}_is1', 'UninstallString', ResultStr)
if ResultStr='' then
begin
Result := True;
end
else
ResultStr:=RemoveQuotes(ResultStr);
Exec(ResultStr, '', '', SW_SHOWNORMAL, ewNoWait, ResultCode)
end;
//-------------------- Поиск приложений через реестр - Конец --------------------\\
//-------------------- Удаление сохранений - Начало --------------------\\
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep=usDone then
begin
if DirExists(ExpandConstant('{userdocs}\Сохранения')) then
begin
if MsgBox('Удалить сохраненные игры?',mbconfirmation, mb_yesno) = IDYES then
begin
DelTree(ExpandConstant('{userdocs}\Сохранения'), True, True, True);
end;
end;
end;
end;
//-------------------- Удаление сохранений - Конец --------------------\\

//-------------------- Проверка требований системы (Черный стиль - Исправил немного) - Начало --------------------\\
type
PDisplay_Device = record
cb: DWord;
DeviceName: array [0..31] of char;
DeviceString: array [0..127] of char;
StateFlags: DWord;
DeviceID, DeviceKey: array [0..127] of char;
end;

TMixerCaps = record
vPid, vDriverVersion: DWord;
sName: array [0..31] of char;
Support, cDestinations: DWord;
end;

// Проверка версии Windows
#if Pos("4.", GetFileVersion(AddBackslash(GetEnv("windir")) + "Explorer.exe")) == 1
{Win9x}
TMemoryStatusEx = record
dwLength, dwMemoryLoad: DWord;
LoTotalPhys, LoAvailPhys, LoTotalPageFile, LoAvailPageFile,
LoTotalVirtual, LoAvailVirtual, LoAvailExtendedVirtual, HiTotalPhys,
HiAvailPhys, HiTotalPageFile, HiAvailPageFile, HiTotalVirtual, HiAvailVirtual,
HiAvailExtendedVirtual: Integer;
end;
function GlobalMemoryStatusEx(var lpBuffer: TMemoryStatusEx): Boolean;
external 'GlobalMemoryStatus@kernel32.dll stdcall';
#else
{WinNT}
TMemoryStatusEx = record
dwLength, dwMemoryLoad: DWord;
LoTotalPhys, HiTotalPhys, LoAvailPhys, HiAvailPhys,
LoTotalPageFile, HiTotalPageFile, LoAvailPageFile, HiAvailPageFile,
LoTotalVirtual, HiTotalVirtual, LoAvailVirtual, HiAvailVirtual, LoAvailExtendedVirtual,
HiAvailExtendedVirtual: Integer;
end;
function GlobalMemoryStatusEx(var lpBuffer: TMemoryStatusEx): Boolean;
external 'GlobalMemoryStatusEx@kernel32.dll stdcall';
#endif

const
DISPLAY_DEVICE_PRIMARY_DEVICE = 4;
oneMB = 1024*1024;
NeedMHz = 1600;
NeedVideoRAM = 64;
NeedSoundCard = 'Realtek HD';
NeedMB = 512;
NeedPageFile = 1048;

var
InfoPage: TWizardPage;
TopText, BottomText: TNewStaticText;
ChangeText: Boolean;
SystemPanel, ProcessorPanel, VideoPanel,
AudioPanel, RAMPanel, PageFilePanel: TMemo;
SystemVersionPanel, ProcessorMHzPanel, VideoRAMPanel,
AudioNamePanel, RAMTotalPanel, PageFileTotalPanel: TMemo;
lpCaps: TMixerCaps;
Version: TWindowsVersion;
MemoryEx: TMemoryStatusEx;
n, errCode: Integer;
Keys: TArrayOfString;
DeviceValue: Cardinal;
lpDisplayDevice: PDisplay_Device;

function GetSystemMetrics(nIndex: Integer): Integer;
external 'GetSystemMetrics@user32.dll stdcall';

function GetDeviceCaps(hDC, nIndex: Integer): Integer;
external 'GetDeviceCaps@GDI32 stdcall';

function CreateDC(lpDriverName, lpDeviceName, lpOutput: String; lpInitData: Integer): Integer;
external 'CreateDCA@GDI32 stdcall';

function EnumDisplayDevices(lpDevice, iDevNum: DWord; var lpDisplayDevice: PDisplay_Device; dwFlags: DWord): Boolean;
external 'EnumDisplayDevicesA@user32.dll stdcall';

function mixerGetDevCaps(uDeviceID: LongInt; var lpCaps: TMixerCaps; uSize: LongInt): LongInt;
external 'mixerGetDevCapsA@winmm.dll stdcall';

function mixerGetNumDevs: Integer;
external 'mixerGetNumDevs@winmm.dll stdcall';

// Дополнить число до кратного Multiple
function ToMultiple(Bytes, Multiple: Integer): Integer;
begin
if Abs(Bytes/Multiple) > Bytes/Multiple then
Result := (Bytes/Multiple + 1)*Multiple
else
Result := Bytes
end;

// Перевод числа в значение Бт/Кб/Мб/Гб/Тб (до 3х знаков после запятой)
function ByteOrTB(Bytes: Extended; noMB: Boolean): String;
begin
if not noMB then
Result := FloatToStr(Int(Bytes)) + ' Мб'
else
if Bytes < 1024 then
Result := FloatToStr(Int(Bytes)) + ' Бт'
else
if Bytes/1024 < 1024 then
Result := FloatToStr(round((Bytes/1024)*10)/10) + ' Кб'
else
if Bytes/oneMB < 1024 then
Result := FloatToStr(round(Bytes/oneMB*100)/100) + ' Мб'
else
if Bytes/oneMB/1000 < 1024 then
Result := FloatToStr(round(Bytes/oneMB/1024*1000)/1000) + ' Гб'
else
Result := FloatToStr(round(Bytes/oneMB/oneMB*1000)/1000) + ' Тб'
StringChange(Result, ',', '.')
end;

// Удаление начальных, конечных и повторных пробелов
function DelSp(String: String): String;
begin
while (Pos(' ', String) > 0) do Delete(String, Pos(' ', String), 1)
Result := Trim(String)
end;

function Size64(Hi, Lo: Integer): Extended;
begin
Result := Lo
if Lo < 0 then
Result := Result + $7FFFFFFF + $7FFFFFFF + 2
for Hi := Hi-1 downto 0 do Result := Result + $7FFFFFFF + $7FFFFFFF + 2
end;

function CheckCPU(NeedMHz: Integer): Boolean;
var
String: String;
begin
String := 'Hardware\Description\System\CentralProcessor'; RegGetSubkeyNames(HKLM, String, Keys) // Количество ядер
for n := 0 to GetArrayLength(Keys)-1 do
RegQueryStringValue(HKLM, String + '\' + Keys[n], 'ProcessorNameString', Keys[n])
if not RegQueryDWordValue(HKLM, String + '\0', '~MHz', DeviceValue) or (DeviceValue < NeedMHz) then
Exit
else
Result := True
end;

function CheckMemorySize(NeedRAM: Integer): Boolean;
begin
MemoryEx.dwLength := SizeOf(MemoryEx)
if not GlobalMemoryStatusEx(MemoryEx) then
MsgBox('Ошибка функции:' + #13 + 'GlobalMemoryStatusEx', mbError, mb_Ok)
else
if (ToMultiple(trunc(Size64(MemoryEx.HiTotalPhys, MemoryEx.LoTotalPhys)/oneMB), 16) < NeedRAM) then
Exit
else
Result := True
end;

procedure CreateCheckForm();
begin

TopText := TNewStaticText.Create(InfoPage)
with TopText do
begin
Parent := InfoPage.Surface
Left := 0
AutoSize := True
end

BottomText := TNewStaticText.Create(InfoPage)
with BottomText do
begin
Parent := InfoPage.Surface
Caption := 'Когда Вы будете готовы продолжить установку, нажмите «Далее»'
Font.Color := clGray
Left := 0
Top := 200
AutoSize := True
end

SystemPanel := TMemo.Create(InfoPage)
with SystemPanel do
begin
Text := 'Система'
Alignment := taCenter
Parent := InfoPage.Surface
Left := ScaleX(0)
Top := ScaleY(33)
Width := ScaleX(100)
Height := ScaleY(22)
ReadOnly := True
Color := clBlack
Font.Color := clWhite
end

SystemVersionPanel := TMemo.Create(InfoPage)
with SystemVersionPanel do
begin
Alignment := taLeftJustify
Parent := InfoPage.Surface
Left := ScaleX(104)
Top := SystemPanel.Top
Width := ScaleX(310)
Height := ScaleY(22)
ReadOnly := True
end

ProcessorPanel := TMemo.Create(InfoPage)
with ProcessorPanel do
begin
Text := 'Процессор'
Alignment := taCenter
Parent := InfoPage.Surface
Left := ScaleX(0)
Top := SystemPanel.Top + 27
Width := ScaleX(100)
Height := ScaleY(22)
ReadOnly := True
Color := clBlack
Font.Color := clWhite
end

ProcessorMHzPanel := TMemo.Create(InfoPage)
with ProcessorMHzPanel do
begin
Alignment := taLeftJustify
Parent := InfoPage.Surface
Left := ScaleX(104)
Top := ProcessorPanel.Top
Width := ScaleX(310)
Height := ScaleY(22)
ReadOnly := True
end

VideoPanel := TMemo.Create(InfoPage)
with VideoPanel do
begin
Text := 'Видеоадаптер'
Alignment := taCenter
Parent := InfoPage.Surface
Left := ScaleX(0)
Top := ProcessorPanel.Top + 27
Width := ScaleX(100)
Height := ScaleY(22)
ReadOnly := True
Color := clBlack
Font.Color := clWhite
end

VideoRAMPanel := TMemo.Create(InfoPage)
with VideoRAMPanel do
begin
Alignment := taLeftJustify
Parent := InfoPage.Surface
Left := ScaleX(104)
Top := VideoPanel.Top
Width := ScaleX(310)
Height := ScaleY(22)
ReadOnly := True
end

AudioPanel := TMemo.Create(InfoPage)
with AudioPanel do
begin
Text := 'Звуковая карта'
Alignment := taCenter
Parent := InfoPage.Surface
Left := ScaleX(0)
Top := VideoPanel.Top + 27
Width := ScaleX(100)
Height := ScaleY(22)
ReadOnly := True
Color := clBlack
Font.Color := clWhite
end

AudioNamePanel := TMemo.Create(InfoPage)
with AudioNamePanel do
begin
Alignment := taLeftJustify
Parent := InfoPage.Surface
Left := ScaleX(104)
Top := AudioPanel.Top
Width := ScaleX(310)
Height := ScaleY(22)
ReadOnly := True
end

RAMPanel := TMemo.Create(InfoPage)
with RAMPanel do
begin
Text := 'Объём памяти'
Alignment := taCenter
Parent := InfoPage.Surface
Left := ScaleX(0)
Top := AudioPanel.Top + 27
Width := ScaleX(100)
Height := ScaleY(22)
ReadOnly := True
Color := clBlack
Font.Color := clWhite
end

RAMTotalPanel := TMemo.Create(InfoPage)
with RAMTotalPanel do
begin
Alignment := taLeftJustify
Parent := InfoPage.Surface
Left := ScaleX(104)
Top := RAMPanel.Top
Width := ScaleX(310)
Height := ScaleY(22)
ReadOnly := True
end

PageFilePanel := TMemo.Create(InfoPage)
with PageFilePanel do
begin
Text := 'Файл подкачки'
Alignment := taCenter
Parent := InfoPage.Surface
Left := ScaleX(0)
Top := RAMPanel.Top + 27
Width := ScaleX(100)
Height := ScaleY(22)
ReadOnly := True
Color := clBlack
Font.Color := clWhite
end;

PageFileTotalPanel := TMemo.Create(InfoPage)
with PageFileTotalPanel do
begin
Alignment := taLeftJustify
Parent := InfoPage.Surface
Left := ScaleX(104)
Top := PageFilePanel.Top
Width := ScaleX(310)
Height := ScaleY(22)
ReadOnly := True
end

end;

procedure UpdateInfo();
var
DeviceName, DeviceKey: String;
begin
ChangeText := False

GetWindowsVersionEx(Version)

// Операционная система:
SystemVersionPanel.Color := clBlack
SystemVersionPanel.Font.Color := clGreen

DeviceKey := 'Software\Microsoft\Windows NT\CurrentVersion'
if not UsingWinNT then StringChange(DeviceKey, 'Windows NT', 'Windows')
RegQueryStringValue(HKLM, DeviceKey, 'ProductName', DeviceName)
if RegQueryStringValue(HKLM, DeviceKey, 'CSDVersion', DeviceKey) then
DeviceName := DeviceName + ' ' + DeviceKey
StringChange(DeviceName, 'Microsoft ', '')
SystemVersionPanel.Text := ' ' + DeviceName + ' сборка ' + IntToStr(Version.Major) + '.' + IntToStr(Version.Minor) +
'.' + IntToStr(Version.Build)

if (Pos('2000 Service Pack 4', SystemVersionPanel.Text) = 0) and // Windows 2000 SP4
(Pos('XP Service Pack 2', SystemVersionPanel.Text) = 0) and // Windows XP SP2
(Pos('XP Service Pack 3', SystemVersionPanel.Text) = 0) and // Windows XP SP3
(Pos('Vista', SystemVersionPanel.Text) = 0) then // Windows Vista (c любым SP или без него)
begin
SystemVersionPanel.Color := clBlack
SystemVersionPanel.Font.Color := clRed
ChangeText := True
end

// Процессор:
ProcessorMHzPanel.Color := clBlack
ProcessorMHzPanel.Font.Color := clGreen

if not CheckCPU(NeedMHz) then
begin
ProcessorMHzPanel.Color := clBlack
ProcessorMHzPanel.Font.Color := clRed
ChangeText := True
end

ProcessorMHzPanel.Text := ' ' + DelSp(Keys[0]) + ' @' + IntToStr(DeviceValue) + ' MHz'
if GetArrayLength(Keys) > 1 then
ProcessorPanel.Text := 'Процессоры' // + ' (' + IntToStr(GetArrayLength(Keys)) + ')'

// Видеокарта:
VideoRAMPanel.Color := clBlack
VideoRAMPanel.Font.Color := clGreen

lpDisplayDevice.cb := SizeOf(lpDisplayDevice)
DeviceKey := ''
n := 0
while not (EnumDisplayDevices(0, n, lpDisplayDevice, 0) and
(lpDisplayDevice.StateFlags and DISPLAY_DEVICE_PRIMARY_DEVICE > 0)) and (n < 127) do n := n + 1
for n := 0 to 127 do DeviceKey := DeviceKey + lpDisplayDevice.DeviceKey[n]
Delete(DeviceKey, Pos(Chr(0), DeviceKey), 127) // Ключ драйвера получаем из API
StringChange(DeviceKey, '\Registry\Machine\', '')
errCode := 1
DeviceValue := 0
if RegQueryBinaryValue(HKLM, DeviceKey, 'HardwareInformation.MemorySize', DeviceName) then
for n := 1 to Length(DeviceName) do
begin
DeviceValue := DeviceValue + Ord(DeviceName[n])*errCode
errCode := errCode*$100
end
else
if RegQueryDWordValue(HKLM, DeviceKey, 'HardwareInformation.MemorySize', DeviceValue) then
else
RegQueryDWordValue(HKLM, DeviceKey + '\Info', 'VideoMemory', DeviceValue)
DeviceName := ''
for n := 0 to 127 do DeviceName := DeviceName + lpDisplayDevice.DeviceString[n]
Delete(DeviceName, Pos(Chr(0), DeviceName), 127)

if DeviceName <> '' then
if DeviceValue > 0 then
VideoRAMPanel.Text := ' ' + DelSp(DeviceName) + ', '+ ByteOrTB(DeviceValue/oneMB, False)
else
VideoRAMPanel.Text := ' ' + DelSp(DeviceName) + ' (Standard), '+ ByteOrTB(DeviceValue/oneMB, False)
else
begin
VideoRAMPanel.Text := ' Драйвер устройства не обнаружен'
VideoRAMPanel.Color := clBlack
VideoRAMPanel.Font.Color := clRed
ChangeText := True
end
if (DeviceValue/oneMB < NeedVideoRAM) then
begin
VideoRAMPanel.Color := clBlack
VideoRAMPanel.Font.Color := clRed
ChangeText := True
end
VideoRAMPanel.Text := VideoRAMPanel.Text + ', ' + IntToStr(GetSystemMetrics(0)) + 'x' +
IntToStr(GetSystemMetrics(1)) + ' (' + IntToStr(GetDeviceCaps(CreateDC('DISPLAY','','',0),14) *
GetDeviceCaps(CreateDC('DISPLAY','','',0),12)) + ' bit)'

// Звуковая карта:
AudioNamePanel.Color := clBlack
AudioNamePanel.Font.Color := clGreen

// for errCode := 0 to 1 do // Вывод основного звукового устройства
for errCode := 0 to mixerGetNumDevs do
begin
mixerGetDevCaps(errCode-1, lpCaps, SizeOf(lpCaps))
DeviceName := ' '
for n := 0 to 31 do DeviceName := DeviceName + lpCaps.sName[n]
Delete(DeviceName, Pos(Chr(0), DeviceName), 31)
Delete(DeviceName, Pos(' [', DeviceName), 31)
StringChange(DeviceName, 'SB ', 'Creative ')
Delete(DeviceName, Pos(' Audio', DeviceName), 31)
SetArrayLength(Keys, errCode)
if errCode > 0 then Keys[errCode-1] := DeviceName
end

if GetArrayLength(Keys) > 1 then
begin
AudioPanel.Text := 'Звуковые карты'
// AudioPanel.Text := 'Звуковые карты (' + IntToStr(GetArrayLength(Keys)) +')'
AudioNamePanel.Text := ''
for n := 1 to GetArrayLength(Keys) do
AudioNamePanel.Text := AudioNamePanel.Text + Keys[n-1] // + '(' + IntToStr(n) + ')'
end
else
if GetArrayLength(Keys) = 0 then
begin
AudioNamePanel.Text := ' Драйвер устройства не обнаружен'
AudioNamePanel.Color := clBlack
AudioNamePanel.Font.Color := clRed
ChangeText := True
end
else
AudioNamePanel.Text := Keys[0]
if Pos(NeedSoundCard, AudioNamePanel.Text) = 0 then
AudioNamePanel.Text := AudioNamePanel.Text + ' (рекомендуется ' + NeedSoundCard + ')'

// Объём памяти:
RAMTotalPanel.Color := clBlack
RAMTotalPanel.Font.Color := clGreen
if not CheckMemorySize(NeedMB) then
begin
RAMTotalPanel.Color := clBlack
RAMTotalPanel.Font.Color := clRed
ChangeText := True
end
RAMTotalPanel.Text := ' ' + ByteOrTB(ToMultiple(trunc(Size64(MemoryEx.HiTotalPhys, MemoryEx.LoTotalPhys)/oneMB), 16), False) + ' всего, ' +
ByteOrTB(ToMultiple(trunc(Size64(MemoryEx.HiTotalPhys, MemoryEx.LoTotalPhys)/oneMB), 16) -
Size64(MemoryEx.HiAvailPhys, MemoryEx.LoAvailPhys)/oneMB, False) + ' используется, ' +
ByteOrTB(Size64(MemoryEx.HiAvailPhys, MemoryEx.LoAvailPhys)/oneMB, False) + ' свободно'

// Виртуальная память:
PageFileTotalPanel.Color := clBlack
PageFileTotalPanel.Font.Color := clGreen
PageFileTotalPanel.Text := ' ' + ByteOrTB(Size64(MemoryEx.HiTotalPageFile, MemoryEx.LoTotalPageFile)/oneMB, False) + ' всего, ' +
ByteOrTB((Size64(MemoryEx.HiTotalPageFile, MemoryEx.LoTotalPageFile) -
Size64(MemoryEx.HiAvailPageFile, MemoryEx.LoAvailPageFile))/oneMB, False) + ' занято системным кэшем'
if Size64(MemoryEx.HiTotalPageFile, MemoryEx.LoTotalPageFile)/oneMB < NeedPageFile then
begin
PageFileTotalPanel.Color := clBlack
PageFileTotalPanel.Font.Color := clRed
ChangeText := True
end

if ChangeText = True then
begin
TopText.Top := 0
TopText.Caption := 'Не все компоненты удовлетворяют минимальным требованиям игры.' #13
'Пожалуйста, проверьте позиции, выделенные красным цветом.'
TopText.Font.Color := clRed
// WizardForm.NextButton.Enabled := False
end
else
begin
TopText.Caption := 'Все компоненты соответствуют минимальным требованиям игры.'
TopText.Font.Color := clGreen
TopText.Top := 8
// WizardForm.NextButton.Enabled := True
end
end;

procedure InitializeWizard1();
begin
InfoPage := CreateCustomPage(wpLicense, 'Аппаратное и программное обеспечение',
'Программа установки обнаружила следующие наобходимые компоненты.')
CreateCheckForm() // Создание объектов TMemo, в которых будет выводится информация о системе
UpdateInfo() // Обновление информации о системе
end;

procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = InfoPage.ID then UpdateInfo() // Обновление информации о системе
end;
//-------------------- Проверка требований системы (Черный стиль) - Конец --------------------\\


//-------------------- Скин + Музыка - Начало --------------------\\
type
HSTREAM=DWORD;
TTimerProc=procedure(uTimerID,uMessage:UINT;dwUser,dw1,dw2:DWORD);
var
MP3List:TStringList;
CurrentMP3:integer;
hMP3:HWND;
TimerID:LongWord;

function BASS_ChannelIsActive(Handle:HWND):DWORD; external 'BASS_ChannelIsActive@files:bass.dll stdcall';
function BASS_SetConfig(Option,Value:DWORD):DWORD; external 'BASS_SetConfig@files:bass.dll stdcall';
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):HSTREAM; external 'BASS_StreamCreateFile@files:bass.dll stdcall';
function BASS_StreamFree(Handle:HWND):boolean; external 'BASS_StreamFree@files:bass.dll stdcall';
function BASS_ChannelPlay(Handle:HWND;Restart:boolean):boolean; external 'BASS_ChannelPlay@files:bass.dll stdcall';
function BASS_Start: Boolean; external 'BASS_Start@files:bass.dll stdcall';
function BASS_Stop: Boolean; external 'BASS_Stop@files:bass.dll stdcall';
function BASS_Free: Boolean; external 'BASS_Free@files:bass.dll stdcall delayload';
function SetTimer(hWnd:HWND;nIDEvent,uElapse:UINT;lpTimerFunc:LongWord{TFNTimerProc}):UINT; external 'SetTimer@user32.dll stdcall delayload';
function KillTimer(hWnd:HWND;uIDEvent:UINT):BOOL; external 'KillTimer@user32.dll stdcall delayload';
function WrapTimerProc(CallBack:TTimerProc;ParamCount:integer):LongWord; external 'wrapcallback@files:innocallback.dll stdcall';
procedure LoadSkin(lpszPath: String; lpszIniFileName: String); external 'LoadSkin@files:isskin.dll stdcall';
procedure UnloadSkin(); external 'UnloadSkin@files:isskin.dll stdcall';
function ShowWindow(hWnd: Integer; uType: Integer): Integer; external 'ShowWindow@user32.dll stdcall';

procedure TimerTick(uTimerID,uMessage:UINT;dwUser,dw1,dw2:DWORD);
begin
if BASS_ChannelIsActive(hMP3)=0 then begin
BASS_Stop;
BASS_StreamFree(hMP3);
hMP3:=BASS_StreamCreateFile(False,PChar(MP3List.Strings[CurrentMP3]),0,0,0);
BASS_Start;
if hMP3<>0 then
if BASS_ChannelPlay(hMP3,True) then begin
CurrentMP3:=CurrentMP3+1;
if CurrentMP3>MP3List.Count-1 then CurrentMP3:=0;
end;
end;
end;

function InitializeSetup2():boolean;
begin
ExtractTemporaryFile('Play.mp3');
MP3List:=TStringList.Create;
MP3List.Add(ExpandConstant('{tmp}')+'\Play.mp3');
CurrentMP3:=0;
ExtractTemporaryFile('tiger_v2.cjstyles');
LoadSkin(ExpandConstant('{tmp}')+'\tiger_v2.cjstyles', '');
Result:=True;
end;

procedure InitializeWizard2();
begin
TimerID:=SetTimer(0,0,500,WrapTimerProc(@TimerTick,5));
BASS_Init(-1,44100,0,0,0);
BASS_SetConfig(5,100);
BASS_SetConfig(6,100);
WizardForm.BeveledLabel.Enabled:=True;
end;

procedure DeinitializeSetup;
begin
KillTimer(0,TimerID);
BASS_Stop;
BASS_Free;
MP3List.Free;
ShowWindow(WizardForm.Handle,0);
UnloadSkin();
end;

//-------------------- Скин + Музыка - конец --------------------\\

function InitializeSetup(): Boolean;
begin
InitializeSetup1();
InitializeSetup2();
end;

procedure InitializeWizard();
InitializeWizard1();
InitializeWizard2();
end;

Gnom_aka_Lexander
02-02-2011, 11:12
Neutron,
[Setup]
AppID={{085F49CD-C119-49BC-8130-65E06ACBF728}
AppName=Manhunt
AppVerName=Manhunt
AppVersion=1.1001.0
DefaultDirName={pf}\Games\Manhunt
DefaultGroupName=Games\Manhunt
AllowNoIcons=yes
OutputBaseFilename=setup
WindowVisible=false
WindowShowCaption=false
WindowResizable=false
Compression=lzma/normal
SourceDir=.
OutputDir=.
WizardImageFile=Data\Big.bmp

[Languages]
Name: russian; MessagesFile: compiler:Languages\Russian.isl

[Tasks]
Name: select; Description: Дополнительно;
Name: select\DirectX; Description: Обновить DirectX;

[Run]
Filename: {src}\DXSetup.exe; Parameters: /SILENT; Flags: skipifdoesntexist postinstall; StatusMsg: Устанавливается DirectX; Tasks: select\DirectX


[Components]
Name: r; Description: Russian; Types: rus
Name: e; Description: English; Types: eng

[Types]
Name: rus; Description: Русская версия
Name: eng; Description: English version


[Files]
Source: Data\ISSkin.dll; DestDir: {tmp}; Flags: ignoreversion dontcopy nocompression
Source: Data\tiger_v2.cjstyles; DestDir: {tmp}; Flags: ignoreversion dontcopy nocompression
Source: Data\bass.dll; DestDir: {tmp}; Flags: ignoreversion dontcopy nocompression
Source: Data\innocallback.dll; DestDir: {tmp}; Flags: ignoreversion dontcopy nocompression
Source: Data\Play.mp3; DestDir: {tmp}; Flags: ignoreversion dontcopy nocompression

;Папка с игрой
;--------------
;Source: Games\*; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs sortfilesbyextension
Source: Data\ISSkin.dll; DestDir: {app}; Flags: ignoreversion nocompression
Source: Data\tiger_v2.cjstyles; DestDir: {app}; Flags: ignoreversion nocompression

;Локализация

[Messages]
SetupWindowTitle=Manhunt

[Icons]
Name: {group}\{cm:UninstallProgram,}; Filename: {uninstallexe}

[UninstallDelete]
Type: filesandordirs; Name: {app}

[_Code]
//==================== Начало =====================
type
HSTREAM=DWORD;
TTimerProc=procedure(uTimerID,uMessage:UINT;dwUser,dw1,dw2:DWORD);
var
MP3List:TStringList;
CurrentMP3:integer;
hMP3:HWND;
TimerID:LongWord;

function SetTimer(hWnd:HWND;nIDEvent,uElapse:UINT;lpTimerFunc:LongWord{TFNTimerProc}):UINT; external 'SetTimer@user32.dll stdcall delayload';
function KillTimer(hWnd:HWND;uIDEvent:UINT):BOOL; external 'KillTimer@user32.dll stdcall delayload';
function BASS_ChannelIsActive(Handle:HWND):DWORD; external 'BASS_ChannelIsActive@files:bass.dll stdcall';
function BASS_SetConfig(Option,Value:DWORD):DWORD; external 'BASS_SetConfig@files:bass.dll stdcall';
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):HSTREAM; external 'BASS_StreamCreateFile@files:bass.dll stdcall';
function BASS_StreamFree(Handle:HWND):boolean; external 'BASS_StreamFree@files:bass.dll stdcall';
function BASS_ChannelPlay(Handle:HWND;Restart:boolean):boolean; external 'BASS_ChannelPlay@files:bass.dll stdcall';
function BASS_Start: Boolean; external 'BASS_Start@files:bass.dll stdcall';
function BASS_Stop: Boolean; external 'BASS_Stop@files:bass.dll stdcall';
function BASS_Free: Boolean; external 'BASS_Free@files:bass.dll stdcall delayload';
function WrapTimerProc(CallBack:TTimerProc;ParamCount:integer):LongWord; external 'wrapcallback@files:innocallback.dll stdcall';
procedure LoadSkin(lpszPath: String; lpszIniFileName: String); external 'LoadSkin@files:isskin.dll stdcall';
procedure UnloadSkin(); external 'UnloadSkin@files:isskin.dll stdcall';
function ShowWindow(hWnd: Integer; uType: Integer): Integer; external 'ShowWindow@user32.dll stdcall';

procedure TimerTick(uTimerID,uMessage:UINT;dwUser,dw1,dw2:DWORD);
begin
if BASS_ChannelIsActive(hMP3)=0 then begin
BASS_Stop;
BASS_StreamFree(hMP3);
hMP3:=BASS_StreamCreateFile(False,PChar(MP3List.Strings[CurrentMP3]),0,0,0);
BASS_Start;
if hMP3<>0 then
if BASS_ChannelPlay(hMP3,True) then begin
CurrentMP3:=CurrentMP3+1;
if CurrentMP3>MP3List.Count-1 then CurrentMP3:=0;
end;
end;
end;

function InitializeSetup1:boolean;
begin
ExtractTemporaryFile('Play.mp3');
MP3List:=TStringList.Create;
MP3List.Add(ExpandConstant('{tmp}')+'\Play.mp3');
CurrentMP3:=0;
ExtractTemporaryFile('tiger_v2.cjstyles');
LoadSkin(ExpandConstant('{tmp}')+'\tiger_v2.cjstyles', '');
Result:=True;
end;

procedure InitializeWizard1;
begin
TimerID:=SetTimer(0,0,500,WrapTimerProc(@TimerTick,5));
BASS_Init(-1,44100,0,0,0);
BASS_SetConfig(5,100);
BASS_SetConfig(6,100);
WizardForm.BeveledLabel.Enabled:=True;
end;

procedure DeinitializeSetup1;
begin
KillTimer(0,TimerID);
BASS_Stop;
BASS_Free;
MP3List.Free;
ShowWindow(WizardForm.Handle,0);
UnloadSkin();
end;

//=========== Системные требования - Начало ===========
type
PDisplay_Device = record
cb: DWord;
DeviceName: array [0..31] of char;
DeviceString: array [0..127] of char;
StateFlags: DWord;
DeviceID, DeviceKey: array [0..127] of char;
end;

TMixerCaps = record
vPid, vDriverVersion: DWord;
sName: array [0..31] of char;
Support, cDestinations: DWord;
end;

// Проверка версии Windows
#if Pos("4.", GetFileVersion(AddBackslash(GetEnv("windir")) + "Explorer.exe")) == 1
{Win9x}
TMemoryStatusEx = record
dwLength, dwMemoryLoad: DWord;
LoTotalPhys, LoAvailPhys, LoTotalPageFile, LoAvailPageFile,
LoTotalVirtual, LoAvailVirtual, LoAvailExtendedVirtual, HiTotalPhys,
HiAvailPhys, HiTotalPageFile, HiAvailPageFile, HiTotalVirtual, HiAvailVirtual,
HiAvailExtendedVirtual: Integer;
end;
function GlobalMemoryStatusEx(var lpBuffer: TMemoryStatusEx): Boolean;
external 'GlobalMemoryStatus@kernel32.dll stdcall';
#else
{WinNT}
TMemoryStatusEx = record
dwLength, dwMemoryLoad: DWord;
LoTotalPhys, HiTotalPhys, LoAvailPhys, HiAvailPhys,
LoTotalPageFile, HiTotalPageFile, LoAvailPageFile, HiAvailPageFile,
LoTotalVirtual, HiTotalVirtual, LoAvailVirtual, HiAvailVirtual, LoAvailExtendedVirtual,
HiAvailExtendedVirtual: Integer;
end;
function GlobalMemoryStatusEx(var lpBuffer: TMemoryStatusEx): Boolean;
external 'GlobalMemoryStatusEx@kernel32.dll stdcall';
#endif

const
DISPLAY_DEVICE_PRIMARY_DEVICE = 4;
oneMB = 1024*1024;
NeedMHz = 2200;
NeedVideoRAM = 256;
NeedSoundCard = 'Realtek HD';
NeedMB = 1024;
NeedPageFile = 2048;

var
InfoPage: TWizardPage;
TopText, BottomText: TNewStaticText;
ChangeText: Boolean;
SystemPanel, ProcessorPanel, VideoPanel,
AudioPanel, RAMPanel, PageFilePanel: TMemo;
SystemVersionPanel, ProcessorMHzPanel, VideoRAMPanel,
AudioNamePanel, RAMTotalPanel, PageFileTotalPanel: TMemo;
lpCaps: TMixerCaps;
Version: TWindowsVersion;
MemoryEx: TMemoryStatusEx;
n, errCode: Integer;
Keys: TArrayOfString;
DeviceValue: Cardinal;
lpDisplayDevice: PDisplay_Device;

function GetSystemMetrics(nIndex: Integer): Integer;
external 'GetSystemMetrics@user32.dll stdcall';

function GetDeviceCaps(hDC, nIndex: Integer): Integer;
external 'GetDeviceCaps@GDI32 stdcall';

function CreateDC(lpDriverName, lpDeviceName, lpOutput: String; lpInitData: Integer): Integer;
external 'CreateDCA@GDI32 stdcall';

function EnumDisplayDevices(lpDevice, iDevNum: DWord; var lpDisplayDevice: PDisplay_Device; dwFlags: DWord): Boolean;
external 'EnumDisplayDevicesA@user32.dll stdcall';

function mixerGetDevCaps(uDeviceID: LongInt; var lpCaps: TMixerCaps; uSize: LongInt): LongInt;
external 'mixerGetDevCapsA@winmm.dll stdcall';

function mixerGetNumDevs: Integer;
external 'mixerGetNumDevs@winmm.dll stdcall';

// Дополнить число до кратного Multiple
function ToMultiple(Bytes, Multiple: Integer): Integer;
begin
if Abs(Bytes/Multiple) > Bytes/Multiple then
Result := (Bytes/Multiple + 1)*Multiple
else
Result := Bytes
end;

// Перевод числа в значение Бт/Кб/Мб/Гб/Тб (до 3х знаков после запятой)
function ByteOrTB(Bytes: Extended; noMB: Boolean): String;
begin
if not noMB then
Result := FloatToStr(Int(Bytes)) + ' Мб'
else
if Bytes < 1024 then
Result := FloatToStr(Int(Bytes)) + ' Бт'
else
if Bytes/1024 < 1024 then
Result := FloatToStr(round((Bytes/1024)*10)/10) + ' Кб'
else
if Bytes/oneMB < 1024 then
Result := FloatToStr(round(Bytes/oneMB*100)/100) + ' Мб'
else
if Bytes/oneMB/1000 < 1024 then
Result := FloatToStr(round(Bytes/oneMB/1024*1000)/1000) + ' Гб'
else
Result := FloatToStr(round(Bytes/oneMB/oneMB*1000)/1000) + ' Тб'
StringChange(Result, ',', '.')
end;

// Удаление начальных, конечных и повторных пробелов
function DelSp(String: String): String;
begin
while (Pos(' ', String) > 0) do Delete(String, Pos(' ', String), 1)
Result := Trim(String)
end;

function Size64(Hi, Lo: Integer): Extended;
begin
Result := Lo
if Lo < 0 then
Result := Result + $7FFFFFFF + $7FFFFFFF + 2
for Hi := Hi-1 downto 0 do Result := Result + $7FFFFFFF + $7FFFFFFF + 2
end;

function CheckCPU(NeedMHz: Integer): Boolean;
var
String: String;
begin
String := 'Hardware\Description\System\CentralProcessor'; RegGetSubkeyNames(HKLM, String, Keys) // Количество ядер
for n := 0 to GetArrayLength(Keys)-1 do
RegQueryStringValue(HKLM, String + '\' + Keys[n], 'ProcessorNameString', Keys[n])
if not RegQueryDWordValue(HKLM, String + '\0', '~MHz', DeviceValue) or (DeviceValue < NeedMHz) then
Exit
else
Result := True
end;

function CheckMemorySize(NeedRAM: Integer): Boolean;
begin
MemoryEx.dwLength := SizeOf(MemoryEx)
if not GlobalMemoryStatusEx(MemoryEx) then
MsgBox('Ошибка функции:' + #13 + 'GlobalMemoryStatusEx', mbError, mb_Ok)
else
if (ToMultiple(trunc(Size64(MemoryEx.HiTotalPhys, MemoryEx.LoTotalPhys)/oneMB), 16) < NeedRAM) then
Exit
else
Result := True
end;

procedure CreateCheckForm();
begin

TopText := TNewStaticText.Create(InfoPage)
with TopText do
begin
Parent := InfoPage.Surface
Left := 0
AutoSize := True
end

BottomText := TNewStaticText.Create(InfoPage)
with BottomText do
begin
Parent := InfoPage.Surface
Caption := 'Когда Вы будете готовы продолжить установку, нажмите «Далее»'
Font.Color := clGray
Left := 0
Top := 200
AutoSize := True
end

SystemPanel := TMemo.Create(InfoPage)
with SystemPanel do
begin
Text := 'Система'
Alignment := taCenter
Parent := InfoPage.Surface
Left := ScaleX(0)
Top := ScaleY(33)
Width := ScaleX(100)
Height := ScaleY(22)
ReadOnly := True
Color := clBlack
end

SystemVersionPanel := TMemo.Create(InfoPage)
with SystemVersionPanel do
begin
Alignment := taLeftJustify
Parent := InfoPage.Surface
Left := ScaleX(104)
Top := SystemPanel.Top
Width := ScaleX(310)
Height := ScaleY(22)
ReadOnly := True
end

ProcessorPanel := TMemo.Create(InfoPage)
with ProcessorPanel do
begin
Text := 'Процессор'
Alignment := taCenter
Parent := InfoPage.Surface
Left := ScaleX(0)
Top := SystemPanel.Top + 27
Width := ScaleX(100)
Height := ScaleY(22)
ReadOnly := True
Color := clBlack
end

ProcessorMHzPanel := TMemo.Create(InfoPage)
with ProcessorMHzPanel do
begin
Alignment := taLeftJustify
Parent := InfoPage.Surface
Left := ScaleX(104)
Top := ProcessorPanel.Top
Width := ScaleX(310)
Height := ScaleY(22)
ReadOnly := True
end

VideoPanel := TMemo.Create(InfoPage)
with VideoPanel do
begin
Text := 'Видеоадаптер'
Alignment := taCenter
Parent := InfoPage.Surface
Left := ScaleX(0)
Top := ProcessorPanel.Top + 27
Width := ScaleX(100)
Height := ScaleY(22)
ReadOnly := True
Color := clBlack
end

VideoRAMPanel := TMemo.Create(InfoPage)
with VideoRAMPanel do
begin
Alignment := taLeftJustify
Parent := InfoPage.Surface
Left := ScaleX(104)
Top := VideoPanel.Top
Width := ScaleX(310)
Height := ScaleY(22)
ReadOnly := True
end

AudioPanel := TMemo.Create(InfoPage)
with AudioPanel do
begin
Text := 'Звуковая карта'
Alignment := taCenter
Parent := InfoPage.Surface
Left := ScaleX(0)
Top := VideoPanel.Top + 27
Width := ScaleX(100)
Height := ScaleY(22)
ReadOnly := True
Color := clBlack
end

AudioNamePanel := TMemo.Create(InfoPage)
with AudioNamePanel do
begin
Alignment := taLeftJustify
Parent := InfoPage.Surface
Left := ScaleX(104)
Top := AudioPanel.Top
Width := ScaleX(310)
Height := ScaleY(22)
ReadOnly := True
end

RAMPanel := TMemo.Create(InfoPage)
with RAMPanel do
begin
Text := 'Объём памяти'
Alignment := taCenter
Parent := InfoPage.Surface
Left := ScaleX(0)
Top := AudioPanel.Top + 27
Width := ScaleX(100)
Height := ScaleY(22)
ReadOnly := True
Color := clBlack
end

RAMTotalPanel := TMemo.Create(InfoPage)
with RAMTotalPanel do
begin
Alignment := taLeftJustify
Parent := InfoPage.Surface
Left := ScaleX(104)
Top := RAMPanel.Top
Width := ScaleX(310)
Height := ScaleY(22)
ReadOnly := True
end

PageFilePanel := TMemo.Create(InfoPage)
with PageFilePanel do
begin
Text := 'Файл подкачки'
Alignment := taCenter
Parent := InfoPage.Surface
Left := ScaleX(0)
Top := RAMPanel.Top + 27
Width := ScaleX(100)
Height := ScaleY(22)
ReadOnly := True
Color := clBlack
end;

PageFileTotalPanel := TMemo.Create(InfoPage)
with PageFileTotalPanel do
begin
Alignment := taLeftJustify
Parent := InfoPage.Surface
Left := ScaleX(104)
Top := PageFilePanel.Top
Width := ScaleX(310)
Height := ScaleY(22)
ReadOnly := True
end

end;

procedure UpdateInfo();
var
DeviceName, DeviceKey: String;
begin
ChangeText := False

GetWindowsVersionEx(Version)

// Операционная система:
SystemVersionPanel.Color := clBlack
SystemVersionPanel.Font.Color := clGreen

DeviceKey := 'Software\Microsoft\Windows NT\CurrentVersion'
if not UsingWinNT then StringChange(DeviceKey, 'Windows NT', 'Windows')
RegQueryStringValue(HKLM, DeviceKey, 'ProductName', DeviceName)
if RegQueryStringValue(HKLM, DeviceKey, 'CSDVersion', DeviceKey) then
DeviceName := DeviceName + ' ' + DeviceKey
StringChange(DeviceName, 'Microsoft ', '')
SystemVersionPanel.Text := ' ' + DeviceName + ' сборка ' + IntToStr(Version.Major) + '.' + IntToStr(Version.Minor) +
'.' + IntToStr(Version.Build)

if (Pos('2000 Service Pack 4', SystemVersionPanel.Text) = 0) and // Windows 2000 SP4
(Pos('XP Service Pack 2', SystemVersionPanel.Text) = 0) and // Windows XP SP2
(Pos('XP Service Pack 3', SystemVersionPanel.Text) = 0) and // Windows XP SP3
(Pos('Vista', SystemVersionPanel.Text) = 0) then // Windows Vista (c любым SP или без него)
begin
SystemVersionPanel.Color := clBlack
SystemVersionPanel.Font.Color := clRed
ChangeText := True
end

// Процессор:
ProcessorMHzPanel.Color := clBlack
ProcessorMHzPanel.Font.Color := clGreen

if not CheckCPU(NeedMHz) then
begin
ProcessorMHzPanel.Color := clBlack
ProcessorMHzPanel.Font.Color := clRed
ChangeText := True
end

ProcessorMHzPanel.Text := ' ' + DelSp(Keys[0]) + ' @' + IntToStr(DeviceValue) + ' MHz'
if GetArrayLength(Keys) > 1 then
ProcessorPanel.Text := 'Процессоры' // + ' (' + IntToStr(GetArrayLength(Keys)) + ')'

// Видеокарта:
VideoRAMPanel.Color := clBlack
VideoRAMPanel.Font.Color := clGreen

lpDisplayDevice.cb := SizeOf(lpDisplayDevice)
DeviceKey := ''
n := 0
while not (EnumDisplayDevices(0, n, lpDisplayDevice, 0) and
(lpDisplayDevice.StateFlags and DISPLAY_DEVICE_PRIMARY_DEVICE > 0)) and (n < 127) do n := n + 1
for n := 0 to 127 do DeviceKey := DeviceKey + lpDisplayDevice.DeviceKey[n]
Delete(DeviceKey, Pos(Chr(0), DeviceKey), 127) // Ключ драйвера получаем из API
StringChange(DeviceKey, '\Registry\Machine\', '')
errCode := 1
DeviceValue := 0
if RegQueryBinaryValue(HKLM, DeviceKey, 'HardwareInformation.MemorySize', DeviceName) then
for n := 1 to Length(DeviceName) do
begin
DeviceValue := DeviceValue + Ord(DeviceName[n])*errCode
errCode := errCode*$100
end
else
if RegQueryDWordValue(HKLM, DeviceKey, 'HardwareInformation.MemorySize', DeviceValue) then
else
RegQueryDWordValue(HKLM, DeviceKey + '\Info', 'VideoMemory', DeviceValue)
DeviceName := ''
for n := 0 to 127 do DeviceName := DeviceName + lpDisplayDevice.DeviceString[n]
Delete(DeviceName, Pos(Chr(0), DeviceName), 127)

if DeviceName <> '' then
if DeviceValue > 0 then
VideoRAMPanel.Text := ' ' + DelSp(DeviceName) + ', '+ ByteOrTB(DeviceValue/oneMB, False)
else
VideoRAMPanel.Text := ' ' + DelSp(DeviceName) + ' (Standard), '+ ByteOrTB(DeviceValue/oneMB, False)
else
begin
VideoRAMPanel.Text := ' Драйвер устройства не обнаружен'
VideoRAMPanel.Color := clBlack
VideoRAMPanel.Font.Color := clRed
ChangeText := True
end
if (DeviceValue/oneMB < NeedVideoRAM) then
begin
VideoRAMPanel.Color := clBlack
VideoRAMPanel.Font.Color := clRed
ChangeText := True
end
VideoRAMPanel.Text := VideoRAMPanel.Text + ', ' + IntToStr(GetSystemMetrics(0)) + 'x' +
IntToStr(GetSystemMetrics(1)) + ' (' + IntToStr(GetDeviceCaps(CreateDC('DISPLAY','','',0),14) *
GetDeviceCaps(CreateDC('DISPLAY','','',0),12)) + ' bit)'

// Звуковая карта:
AudioNamePanel.Color := clBlack
AudioNamePanel.Font.Color := clGreen

// for errCode := 0 to 1 do // Вывод основного звукового устройства
for errCode := 0 to mixerGetNumDevs do
begin
mixerGetDevCaps(errCode-1, lpCaps, SizeOf(lpCaps))
DeviceName := ' '
for n := 0 to 31 do DeviceName := DeviceName + lpCaps.sName[n]
Delete(DeviceName, Pos(Chr(0), DeviceName), 31)
Delete(DeviceName, Pos(' [', DeviceName), 31)
StringChange(DeviceName, 'SB ', 'Creative ')
Delete(DeviceName, Pos(' Audio', DeviceName), 31)
SetArrayLength(Keys, errCode)
if errCode > 0 then Keys[errCode-1] := DeviceName
end

if GetArrayLength(Keys) > 1 then
begin
AudioPanel.Text := 'Звуковые карты'
// AudioPanel.Text := 'Звуковые карты (' + IntToStr(GetArrayLength(Keys)) +')'
AudioNamePanel.Text := ''
for n := 1 to GetArrayLength(Keys) do
AudioNamePanel.Text := AudioNamePanel.Text + Keys[n-1] // + '(' + IntToStr(n) + ')'
end
else
if GetArrayLength(Keys) = 0 then
begin
AudioNamePanel.Text := ' Драйвер устройства не обнаружен'
AudioNamePanel.Color := clBlack
AudioNamePanel.Font.Color := clRed
ChangeText := True
end
else
AudioNamePanel.Text := Keys[0]
if Pos(NeedSoundCard, AudioNamePanel.Text) = 0 then
AudioNamePanel.Text := AudioNamePanel.Text + ' (рекомендуется ' + NeedSoundCard + ')'

// Объём памяти:
RAMTotalPanel.Color := clBlack
RAMTotalPanel.Font.Color := clGreen
if not CheckMemorySize(NeedMB) then
begin
RAMTotalPanel.Color := clBlack
RAMTotalPanel.Font.Color := clRed
ChangeText := True
end
RAMTotalPanel.Text := ' ' + ByteOrTB(ToMultiple(trunc(Size64(MemoryEx.HiTotalPhys, MemoryEx.LoTotalPhys)/oneMB), 16), False) + ' всего, ' +
ByteOrTB(ToMultiple(trunc(Size64(MemoryEx.HiTotalPhys, MemoryEx.LoTotalPhys)/oneMB), 16) -
Size64(MemoryEx.HiAvailPhys, MemoryEx.LoAvailPhys)/oneMB, False) + ' используется, ' +
ByteOrTB(Size64(MemoryEx.HiAvailPhys, MemoryEx.LoAvailPhys)/oneMB, False) + ' свободно'

// Виртуальная память:
PageFileTotalPanel.Color := clBlack
PageFileTotalPanel.Font.Color := clGreen
PageFileTotalPanel.Text := ' ' + ByteOrTB(Size64(MemoryEx.HiTotalPageFile, MemoryEx.LoTotalPageFile)/oneMB, False) + ' всего, ' +
ByteOrTB((Size64(MemoryEx.HiTotalPageFile, MemoryEx.LoTotalPageFile) -
Size64(MemoryEx.HiAvailPageFile, MemoryEx.LoAvailPageFile))/oneMB, False) + ' занято системным кэшем'
if Size64(MemoryEx.HiTotalPageFile, MemoryEx.LoTotalPageFile)/oneMB < NeedPageFile then
begin
PageFileTotalPanel.Color := clBlack
PageFileTotalPanel.Font.Color := clRed
ChangeText := True
end

if ChangeText = True then
begin
TopText.Top := 0
TopText.Caption := 'Не все компоненты удовлетворяют минимальным требованиям игры.' #13
'Пожалуйста, проверьте позиции, выделенные красным цветом.'
TopText.Font.Color := clRed
// WizardForm.NextButton.Enabled := False
end
else
begin
TopText.Caption := 'Все компоненты соответствуют минимальным требованиям игры.'
TopText.Font.Color := clGreen
TopText.Top := 8
// WizardForm.NextButton.Enabled := True
end
end;

procedure InitializeWizard2();
begin
InfoPage := CreateCustomPage(wpLicense, 'Аппаратное и программное обеспечение',
'Программа установки обнаружила следующие наобходимые компоненты.')
CreateCheckForm() // Создание объектов TMemo, в которых будет выводится информация о системе
UpdateInfo() // Обновление информации о системе
end;

procedure CurPageChanged2(CurPageID: Integer);
begin
if CurPageID = InfoPage.ID then UpdateInfo() // Обновление информации о системе
end;
//=========== Системные требования - Коннец ===========

//=========== Автовыбор диска установки - Начало ===========
function GetLogicalDrives: DWORD; external 'GetLogicalDrives@kernel32.dll stdcall';
function GetDriveType(lpRootPathName: PChar): Cardinal; external 'GetDriveTypeA@kernel32.dll stdcall';

const
DRIVE_FIXED = 3;

function NoSD(s: string): string;
var
x, bit, i: Integer;
tp: Cardinal;
sd: string;
begin
sd:= ExpandConstant('{sd}');
Result:= sd;
// Вызываем функцию WinAPI
// Функция возвращает битовую маску установленных логических дисков.
// Бит 0 определяет наличие диска А:, бит 1 - диска B и т.д.
x:= GetLogicalDrives;
if x <> 0 then
// цикл по полученным битам переменной X
for i:= 1 to 64 do
begin
// Накладываем битовую маску для выделения бита с поряковым номером 0
bit:= x and 1;
// нашли логический диск...
if bit = 1 then
begin
// определяем тип логического диска
tp:= GetDriveType(PChar(Chr(64 + i) + ':'));
if tp = DRIVE_FIXED then
// если диск не является системным
if Chr(64 + i) <> Copy(sd, 1, 1) then
begin
Result:= Chr(64 + i) + ':';
Break;
end;
end;
// побитовый сдвиг вправо
x:= x shr 1;
end;
end;
//=========== Автовыбор диска установки - Конец ===========

//=========== Поиск приложений через реестр для деинсталляции - Начало ===========
var
ResultStr:string;
ResultCode: Integer;

function InitializeSetup4(): Boolean;
begin
RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{Введите_AppID}_is1', 'UninstallString', ResultStr)
if ResultStr='' then
begin
Result := True;
end
else
ResultStr:=RemoveQuotes(ResultStr);
Exec(ResultStr, '', '', SW_SHOWNORMAL, ewNoWait, ResultCode)
end;
//=========== Поиск приложений через реестр для деинсталляции - Конец ===========

//=========== Удаление сохранений - Конец ===========
procedure CurUninstallStepChanged5(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep=usDone then
begin
if DirExists(ExpandConstant('{userdocs}\NFS Most Wanted')) then
begin
if MsgBox('Удалить сохраненные игры?',mbconfirmation, mb_yesno) = IDYES then
begin
DelTree(ExpandConstant('{userdocs}\NFS Most Wanted'), True, True, True);
end;
end;
end;
end;
//=========== Удаление сохранений - Конец ===========

//=========== Удаление сохранений - Конец ===========
procedure CurUninstallStepChanged6(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep=usDone then
begin
if DirExists(ExpandConstant('{userdocs}\NFS Most Wanted')) then
begin
if MsgBox('Удалить сохраненные игры?',mbconfirmation, mb_yesno) = IDYES then
begin
DelTree(ExpandConstant('{userdocs}\NFS Most Wanted'), True, True, True);
end;
end;
end;
end;
//=========== Удаление сохранений - Конец ===========


function InitializeSetup(): Boolean;
begin
Result := InitializeSetup1(); if not Result then exit;
Result := InitializeSetup4(); if not Result then exit;
end;

procedure InitializeWizard();
begin
InitializeWizard1();
InitializeWizard2();
end;

procedure DeinitializeSetup();
begin
DeinitializeSetup1();
end;

procedure CurPageChanged(CurPageID: Integer);
begin
CurPageChanged2(CurPageID);
end;

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
CurUninstallStepChanged5(CurUninstallStep);
CurUninstallStepChanged6(CurUninstallStep);
end;

Только нужны твои файлы, чтоб настроить работу. А про скин - в шапке темы есть примеры, там есть и для деинсталляции.
И еще - проще сказать, как ты хочеш, чтоб выглядел инсталлятор, куча мучений иногда отпадает, я по доброте душевной могу сваять скрипт, на примере готового (благо, готовых есть куча в тех-же примерах:) )

Black666angel
03-02-2011, 02:58
Всё нравиться только вот не хватает при деинсталляции! »
Надеюсь эти файлы есть у тебя (ISSkin.dll и *.cjstyles)
[ Setup]
AppName=666
AppVerName=666
DefaultDirName={pf}\Test 666
OutputDir=.

[ Languages]
Name: russian; MessagesFile: compiler:Languages\Russian.isl

[ Files]
Source: ISSkin.dll; DestDir: {app}; Attribs: hidden system
Source: Angel.cjstyles; DestDir: {app}; Attribs: hidden system

[ Code]
function GetSystemMetrics(nIndex: Integer): Integer; external 'GetSystemMetrics@user32.dll stdcall';
procedure LoadSkin(lpszPath: String; lpszIniFileName: String ); external 'LoadSkin@files:isskin.dll stdcall delayload setuponly';
procedure LoadSkinA(lpszPath: String; lpszIniFileName: String ); external 'LoadSkin@{tmp}\isskin.dll stdcall delayload uninstallonly';

function InitializeSetup(): Boolean;
begin
ExtractTemporaryFile('Angel.cjstyles');
LoadSkin(ExpandConstant('{tmp}\Angel.cjstyles'), '');
Result:= true
end;

function InitializeUninstall(): Boolean;
begin
FileCopy(ExpandConstant('{app}\isskin.dll'), ExpandConstant('{tmp}\isskin.dll'), False);
FileCopy(ExpandConstant('{app}\Angel.cjstyles'), ExpandConstant('{tmp}\Angel.cjstyles'), False);
LoadSkinA(ExpandConstant('{tmp}\Angel.cjstyles'), '');
Result:=True;
end;

XNick
03-02-2011, 03:08
Товарищи! Скинте скрипт чтоб можно было растянуть изображения на страницах приветсвия и завершения... (Сам искал ничего нормального не нашел, то в одном шрифт пропадает то в другом ошибка вылетает, в общем вся надежда вас господа!!)

Gnom_aka_Lexander
03-02-2011, 09:11
Neutron, Прошу прощения, здесь в шапке нет примера для работы со скинами, держи во вложении твой скрипт.

Vamp1re
03-02-2011, 14:53
как мне сделать чтоб из установленной папки в процессе установки запускался bat-ник или ехе-шник?

R.i.m.s.k.y.
03-02-2011, 15:01
как мне сделать чтоб из установленной папки в процессе установки запускался bat-ник или ехе-шник? »
[Run]
Filename: {app}\bat.bat; WorkingDir: {app}; Flags: runhidden shellexec

shellexec можно убрать.


или так

[Files]
Source: bat.bat; DestDir: {app}\; AfterInstall: RunBat; Flags: нужные флаги
[_Code]
procedure RunBat();
var res : integer;
begin
Exec(Expandconstant('{app}\bat.bat'), ' /parametrs ',SW_HIDE,ewWaitUntilTerminated,res);
end;


Только учти, если ты будешь в [Files] Source: копировать целую папку, то AfterInstall: RunBat; будет выполняться над каждыым файлов в этой папке и ее подпапках. Так что если надо копировать папку, то сначала копируй ее без AfterInstall: RunBat; а потом отдельную строчку на один мелкий файлик.




© OSzone.net 2001-2012