Войти

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


Страниц : 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

A1EXXX
28-12-2009, 18:56
Inno Setup Compiler [ANSI] Beta 3 (build 091228) English (http://restools.hanzify.org/inno/InnoCompiler_ANSI_BETA3_091228_English(7zip).zip) by Restools (http://restools.hanzify.org/)

REXE
28-12-2009, 19:51
Заниматься или нет переупаковкой, это ваше дело.
Вы должны чётко понимать то, что делаете, т.е. здесь вам подскажут как сделать, но делать за вас никто не будет. »

Я занимаюсь,но почему то люди пишут у кого то работает установка у кого то нет,вот я и попросил чтобы хорошо знающие люди посмотрели может в коде что то не так

xero234
30-12-2009, 00:11
Здравствуйте как я могу это исправить?
Изображение1 (http://img684.imageshack.us/img684/7760/instalator.png)
Изображение2 (http://img17.imageshack.us/img17/3227/instalator2.png)

[Setup]
AppName=My Program
AppVerName=My Program v 1.5
DefaultDirName={pf}\My Program
OutputDir=.
Compression=lzma/ultra
InternalCompressLevel=ultra
SolidCompression=yes

[Languages]


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

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

[Files]
Source: C:\Program Files\Inno Setup 5\Examples\MyProg.exe; DestDir: {app}; Flags: ignoreversion

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

[Code]

var
pnl: TPanel;

///////////////////////WelcomePage//////////////////////////////////////
procedure WelcomePage;
begin
with TLabel.Create(pnl) do
begin
AutoSize:= WizardForm.WelcomeLabel1.AutoSize;
SetBounds(WizardForm.WelcomeLabel1.Left,WizardForm.WelcomeLabel1.Top,
WizardForm.WelcomeLabel1.Width,WizardForm.WelcomeLabel1.Height);
WordWrap:= WizardForm.WelcomeLabel1.WordWrap;
Caption:= WizardForm.WelcomeLabel1.Caption;
with Font do
begin
Color:= clWhite;
Style:= WizardForm.WelcomeLabel1.Font.Style;
Name:= WizardForm.WelcomeLabel1.Font.Name;
Size:= WizardForm.WelcomeLabel1.Font.Size;
end;
Transparent:= True;
Parent:= pnl;
end;
with TLabel.Create(pnl) do
begin
AutoSize:= WizardForm.WelcomeLabel2.AutoSize;
SetBounds(WizardForm.WelcomeLabel2.Left,WizardForm.WelcomeLabel2.Top,
WizardForm.WelcomeLabel2.Width,WizardForm.WelcomeLabel2.Height);
WordWrap:= WizardForm.WelcomeLabel2.WordWrap;
Caption:= WizardForm.WelcomeLabel2.Caption;
with Font do
begin
Color:= clWhite;
Style:= WizardForm.WelcomeLabel2.Font.Style;
Name:= WizardForm.WelcomeLabel2.Font.Name;
Size:= WizardForm.WelcomeLabel2.Font.Size;
end;
Transparent:= True;
Parent:= pnl;
end;
pnl.Repaint;
end;
/////////////////////////////////////////////////////////////////

///////////////////////SelectDirPage//////////////////////////////////////
procedure SelectDirPage;
begin
with WizardForm do
begin
with DirEdit do
begin
Left:= 40;
Top:= 137;
Parent:= pnl;
end;
with DirBrowseButton do
begin
Left:= WizardForm.DirEdit.Left + WizardForm.DirEdit.Width + 10;
Top:= WizardForm.DirEdit.Top - 1;
Parent:= pnl;
end;
with SelectDirBitmapImage do
begin
Left:= WizardForm.DirEdit.Left;
Top:= WizardForm.DirEdit.Top - 62;
Stretch:= True;
Parent:= pnl;
end;
end;
with TLabel.Create(pnl) do
begin
AutoSize:= WizardForm.SelectDirBrowseLabel.AutoSize;
SetBounds(WizardForm.DirEdit.Left,WizardForm.DirEdit.Top - 30,
WizardForm.SelectDirBrowseLabel.Width, WizardForm.SelectDirBrowseLabel.Height);
WordWrap:= WizardForm.SelectDirBrowseLabel.WordWrap;
Caption:= WizardForm.SelectDirBrowseLabel.Caption;
with Font do
begin
Color:= clWhite;
Style:= WizardForm.SelectDirBrowseLabel.Font.Style;
Name:= WizardForm.SelectDirBrowseLabel.Font.Name;
Size:= WizardForm.SelectDirBrowseLabel.Font.Size;
end;
Transparent:= True;
Parent:= pnl;
end;
with TLabel.Create(pnl) do
begin
AutoSize:= WizardForm.SelectDirLabel.AutoSize;
SetBounds(WizardForm.SelectDirBitmapImage.Left + 50,WizardForm.SelectDirBitmapImage.Top + 10,
WizardForm.SelectDirLabel.Width,WizardForm.SelectDirLabel.Height);
WordWrap:= WizardForm.SelectDirLabel.WordWrap;
Caption:= WizardForm.SelectDirLabel.Caption;
with Font do
begin
Color:= clWhite;
Style:= WizardForm.SelectDirLabel.Font.Style;
Name:= WizardForm.SelectDirLabel.Font.Name;
Size:= WizardForm.SelectDirLabel.Font.Size;
end;
Transparent:= True;
Parent:= pnl;
end;
with TLabel.Create(pnl) do
begin
AutoSize:= WizardForm.DiskSpaceLabel.AutoSize;
SetBounds(WizardForm.DirEdit.Left,WizardForm.Bevel.Top - 25,
WizardForm.DiskSpaceLabel.Width,WizardForm.DiskSpaceLabel.Height);
WordWrap:= WizardForm.DiskSpaceLabel.WordWrap;
Caption:= WizardForm.DiskSpaceLabel.Caption;
with Font do
begin
Color:= clWhite;
Style:= WizardForm.DiskSpaceLabel.Font.Style;
Name:= WizardForm.DiskSpaceLabel.Font.Name;
Size:= WizardForm.DiskSpaceLabel.Font.Size;
end;
Transparent:= True;
Parent:= pnl;
end;
pnl.Repaint;
end;
/////////////////////////////////////////////////////////////////

///////////////////////ReadyPage//////////////////////////////////////
procedure ReadyPage;


begin

with TLabel.Create(pnl) do
begin
SetBounds(45,115,WizardForm.ReadyMemo.Width, WizardForm.ReadyMemo.Height);

with Font do
begin
Color:= clWhite;
Style:= WizardForm.ReadyLabel.Font.Style;
Name:= WizardForm.ReadyLabel.Font.Name;
Size:= WizardForm.ReadyLabel.Font.Size;
end;
Transparent:= True;
Parent:= pnl;
end;
with TBevel.Create(WizardForm) do
begin
SetBounds(40,110, WizardForm.ReadyMemo.Width, WizardForm.ReadyMemo.Height);
Parent:= pnl;
end;
with TLabel.Create(pnl) do
begin
AutoSize:= WizardForm.ReadyLabel.AutoSize;
SetBounds(40,70, WizardForm.ReadyLabel.Width, WizardForm.ReadyLabel.Height);
WordWrap:= WizardForm.ReadyLabel.WordWrap;
Caption:= WizardForm.ReadyLabel.Caption;
with Font do
begin
Color:= clWhite;
Style:= WizardForm.ReadyLabel.Font.Style;
Name:= WizardForm.ReadyLabel.Font.Name;
Size:= WizardForm.ReadyLabel.Font.Size;
end;
Transparent:= True;
Parent:= pnl;
end;
pnl.Repaint;
end;

/////////////////////////////////////////////////////////////////

///////////////////////InstallingPage//////////////////////////////////////
procedure InstallingPage;
begin
with WizardForm.ProgressGauge do
begin
Left:= 40;
Top:= 115;
Parent:= pnl;
end;
with TLabel.Create(pnl) do
begin
AutoSize:= WizardForm.FilenameLabel.AutoSize;
SetBounds(WizardForm.ProgressGauge.Left,WizardForm.ProgressGauge.Top-20,
WizardForm.FilenameLabel.Width,WizardForm.FilenameLabel.Height);
WordWrap:= WizardForm.FilenameLabel.WordWrap;
Caption:= WizardForm.FilenameLabel.Caption;
with Font do
begin
Color:= clWhite;
Style:= WizardForm.FilenameLabel.Font.Style;
Name:= WizardForm.FilenameLabel.Font.Name;
Size:= WizardForm.FilenameLabel.Font.Size;
end;
Transparent:= True;
Parent:= pnl;
end;
with TLabel.Create(pnl) do
begin
AutoSize:= WizardForm.StatusLabel.AutoSize;
SetBounds(WizardForm.StatusLabel.Left,WizardForm.StatusLabel.Top,
WizardForm.StatusLabel.Width,WizardForm.StatusLabel.Height);
WordWrap:= WizardForm.StatusLabel.WordWrap;
Caption:= WizardForm.StatusLabel.Caption;
with Font do
begin
Color:= clWhite;
Style:= WizardForm.StatusLabel.Font.Style;
Name:= WizardForm.StatusLabel.Font.Name;
Size:= WizardForm.StatusLabel.Font.Size;
end;
Transparent:= True;
Parent:= pnl;
end;
pnl.Repaint;
end;
/////////////////////////////////////////////////////////////////

///////////////////////FinishedPage//////////////////////////////////////



procedure FinishedPage;
begin

with TLabel.Create(pnl) do
begin
AutoSize:= WizardForm.FinishedHeadingLabel.AutoSize;
SetBounds(WizardForm.FinishedHeadingLabel.Left,WizardForm.FinishedHeadingLabel.Top,
WizardForm.FinishedHeadingLabel.Width,WizardForm.FinishedHeadingLabel.Height);
WordWrap:= WizardForm.FinishedHeadingLabel.WordWrap;
Caption:= WizardForm.FinishedHeadingLabel.Caption;
with Font do
begin
Color:= clWhite;
Style:= WizardForm.FinishedHeadingLabel.Font.Style;
Name:= WizardForm.FinishedHeadingLabel.Font.Name;
Size:= WizardForm.FinishedHeadingLabel.Font.Size;
end;
Transparent:= True;
Parent:= pnl;
end;
with TLabel.Create(pnl) do
begin
AutoSize:= WizardForm.FinishedLabel.AutoSize;
SetBounds(WizardForm.FinishedLabel.Left,WizardForm.FinishedLabel.Top,
WizardForm.FinishedLabel.Width,WizardForm.FinishedLabel.Height);
WordWrap:= WizardForm.FinishedLabel.WordWrap;
Caption:= WizardForm.FinishedLabel.Caption;
with Font do
begin
Color:= clWhite;
Style:= WizardForm.FinishedLabel.Font.Style;
Name:= WizardForm.FinishedLabel.Font.Name;
Size:= WizardForm.FinishedLabel.Font.Size;
end;
Transparent:= True;
Parent:= pnl;
end;
pnl.Repaint;
end;
/////////////////////////////////////////////////////////////////

procedure CurPageChanged(CurPageID: Integer);
begin
pnl:= TPanel.Create(WizardForm);
with pnl do
begin
Align:= alClient;
Parent:= WizardForm;
end;
with WizardForm do
begin
with WizardBitmapImage do
begin
Align:= alClient;
Stretch:= True;
Parent:= pnl;
end;
NextButton.Parent:= pnl;
CancelButton.Parent:= pnl;
BackButton.Parent:= pnl;
Bevel.Parent:= pnl;
pnl.Repaint;
end;

if (CurPageID > wpWelcome) and (CurPageID < wpFinished) then
begin
WizardForm.Bevel1.Parent:= pnl;
with TLabel.Create(pnl) do
begin
AutoSize:= WizardForm.PageNameLabel.AutoSize;
SetBounds(WizardForm.PageNameLabel.Left,WizardForm.PageNameLabel.Top,
WizardForm.PageNameLabel.Width,WizardForm.PageNameLabel.Height);
Caption:= WizardForm.PageNameLabel.Caption;
with Font do
begin
Color:= clWhite;
Style:= WizardForm.PageNameLabel.Font.Style;
Name:= WizardForm.PageNameLabel.Font.Name;
Size:= WizardForm.PageNameLabel.Font.Size;
end;
Transparent:= True;
Parent:= pnl;
end;
with TLabel.Create(pnl) do
begin
AutoSize:= WizardForm.PageDescriptionLabel.AutoSize;
SetBounds(WizardForm.PageDescriptionLabel.Left,WizardForm.PageDescriptionLabel.Top,
WizardForm.PageDescriptionLabel.Width,WizardForm.PageDescriptionLabel.Height);
Caption:= WizardForm.PageDescriptionLabel.Caption;
with Font do
begin
Color:= clWhite;
Style:= WizardForm.PageDescriptionLabel.Font.Style;
Name:= WizardForm.PageDescriptionLabel.Font.Name;
Size:= WizardForm.PageDescriptionLabel.Font.Size;
end;
Transparent:= True;
Parent:= pnl;
end;
pnl.Repaint;
end;

if CurPageID = wpWelcome then WelcomePage;
if CurPageID = wpSelectDir then SelectDirPage;
if CurPageID = wpReady then ReadyPage;
if CurPageID = wpInstalling then InstallingPage;
if CurPageID = wpFinished then FinishedPage;
end;

Serega
30-12-2009, 01:15
как я могу это исправить? »
Только написав эти страницы, по аналогии тем, которые есть в скрипте.

Dark Engel
30-12-2009, 10:04
Коллеги подскажите пожалуйста, как перезагрузить машину через секцию [code]

Serega
30-12-2009, 15:16
как перезагрузить машину через секцию »

[Setup]
AppName=My Program
AppVerName=My Program v 1.5
DefaultDirName={pf}\My Program
OutputDir=.
Compression=lzma/ultra64
InternalCompressLevel=ultra64
SolidCompression=yes

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

[Code]
function InitializeSetup(): Boolean;
var
ResultCode: Integer;
begin
if MsgBox('Желаете перезагрузить компьютер?', mbConfirmation, MB_YESNO) = IDYES then
// Внимание!!! Компьютер сразу будет перезагружен.
Exec('cmd', '/c shutdown -r -f -t 0', '', SW_HIDE, ewNoWait, ResultCode)
else Result:= True;
end;

serg aka lain
30-12-2009, 15:41
Serega, Я бы лучше пользовался function NeedRestart(): Boolean;
Пользователь имеет право выбрать, сейчас ему перезагрузиться, или через неделю.
А такими способами, сразу начинают злоупотреблять, забывают сообщение выдать,
просто молча ... принудительная перезагрузка (встретилась тут, одна такая поделка)

Serega
30-12-2009, 18:13
Пользователь имеет право выбрать, сейчас ему перезагрузиться, или через неделю »
В принципе согласен, надо было указать два варианта. Правда при использовании второго варианта, перезагрузка будет предложена только после установки программы, но бывают случаи, очень редко, что перезагрузка нужна в начале инсталляции. Такое можно увидеть при установке Alcohol'я, когда предлагается перезагрузка в начале инсталляции, для установки необходимой библиотеки.

Пример использования функции NeedRestart:

function NeedRestart(): Boolean;
begin
Result:= True;
end;


P.S.
Откровенно говоря, я просто забыл про эту функцию. Спасибо. ;)

МИШАНЧИК
31-12-2009, 12:39
Всех с наступающим Новым 2010 Годом!
Всем счастья, крепкого здоровья и творческих успехов!

Tukash
31-12-2009, 23:23
всех с новым годом, всего и побольше!!
не подскажите, как сделать чекбокс, с выбором установки озвучки, рус, анг и т.д.!
допустим 2 папки, 1 и 2, в папке 1 русские файлы (не инсталлятор а отдельный файл который надо скопировать для локализации), а в папке 2 (англ файлы) и надо дать возможность выбрать какая локализация нужна !
Заранее спасибо!!!

Habetdin
01-01-2010, 00:59
Tukash, [Types]
Name: custom; Description: Custom installation; Flags: iscustom

[Components]
Name: lng; Description: Language; Types: custom
Name: lng/ru; Description: Русский; Flags: exclusive; Types: custom
Name: lng/en; Description: English; Flags: exclusive

[Files]
Source: Russian\*; DestDir: {app}\Language; Components: lng/ru; Flags: recursesubdirs ignoreversion sortfilesbyextension createallsubdirs
Source: English\*; DestDir: {app}\Language; Components: lng/en; Flags: recursesubdirs ignoreversion sortfilesbyextension createallsubdirs

Tukash
01-01-2010, 16:53
неподскажите как сделать, что-бы нельзя было убрать эту галочку: http://s39.radikal.ru/i086/1001/17/51ea3b6cfeee.jpg (http://www.radikal.ru)
типа она обязательная, а Русская или Англ. по выбору. Укажите что изминить в скрипте:

[Tasks]
Name: desktopicon; Description: Создать значок на рабочем столе

[Types]
Name: custom; Description: Custom installation; Flags: iscustom

[Components]
Name: lng; Description: Выбор Озвучки; Types: custom
Name: lng/ru; Description: Русская; Flags: exclusive
Name: lng/en; Description: English; Flags: exclusive

[Files]
Source: C:\ENG\*; DestDir: {app}\audio\speech; Components: lng/en; Flags: recursesubdirs ignoreversion sortfilesbyextension createallsubdirs
Source: C:\Rus\*; DestDir: {app}\audio\speech; Components: lng/ru; Flags: recursesubdirs ignoreversion sortfilesbyextension createallsubdirs

A1EXXX
01-01-2010, 17:00
Tukash, к "Выбору озвучки" добавь флаг - Flags: fixed;
[Tasks]
Name: desktopicon; Description: Создать значок на рабочем столе

[Types]
Name: custom; Description: Custom installation; Flags: iscustom

[Components]
Name: lng; Description: Выбор Озвучки; Flags: fixed; Types: custom
Name: lng/ru; Description: Русская; Flags: exclusive
Name: lng/en; Description: English; Flags: exclusive

[Files]
Source: C:\ENG\*; DestDir: {app}\audio\speech; Components: lng/en; Flags: recursesubdirs ignoreversion sortfilesbyextension createallsubdirs
Source: C:\Rus\*; DestDir: {app}\audio\speech; Components: lng/ru; Flags: recursesubdirs ignoreversion sortfilesbyextension createallsubdirs

Tukash
01-01-2010, 17:06
A1EXXX,
благодарю!!!

Tukash
01-01-2010, 23:31
чем красивее получается, тем хочется еще лучше))
у меня 2 вопроса!
1. - как здесь самому написать сколько нужно места?
http://i009.radikal.ru/1001/fa/fa2dd7c30585t.jpg (http://radikal.ru/F/i009.radikal.ru/1001/fa/fa2dd7c30585.jpg.html)

2.- как убрать этот чекбокс?(не создавать в меню пуск! или на крайняк добавить туда шрифт)
http://s60.radikal.ru/i168/1001/e3/9434f6d7bfe6t.jpg (http://radikal.ru/F/s60.radikal.ru/i168/1001/e3/9434f6d7bfe6.jpg.html)

A1EXXX
01-01-2010, 23:42
Tukash, чтобы убрать чекбокс, удали строку AllowNoIcons=yes из [Setup]


Код для проверки места на диске: [Code]
var
NeedSize:Integer; FreeMB, TotalMB: Cardinal; NeedSpaceLabel,FreeSpaceLabel: TLabel;

procedure GetFreeSpaceCaption(Sender: TObject);
var
Path: String;
begin
Path := ExtractFileDrive(WizardForm.DirEdit.Text);
GetSpaceOnDisk(Path, True, FreeMB, TotalMB);
if FreeMB > 1024 then
FreeSpaceLabel.Caption := 'Доступно места на диске: '+ FloatToStr(round(FreeMB/1024*100)/100) + ' GB' else
FreeSpaceLabel.Caption := 'Доступно места на диске: '+ IntToStr(FreeMB)+ ' MB';
if FreeMB < NeedSize then
WizardForm.NextButton.Enabled := False else
WizardForm.NextButton.Enabled := True; end;

procedure GetNeedSpaceCaption;
begin
if NeedSize > 1024 then
NeedSpaceLabel.Caption := 'Требуется места на диске: '+ FloatToStr(round(NeedSize/1024*100)/100) + ' GB' else
NeedSpaceLabel.Caption := 'Требуется места на диске: '+ IntToStr(NeedSize)+ ' MB';
end;

procedure InitializeWizard();
begin
NeedSize := 630000;

WizardForm.DiskSpaceLabel.Hide;

NeedSpaceLabel := TLabel.Create(WizardForm);
with NeedSpaceLabel do
begin
Parent := WizardForm.SelectDirPage;
Left := ScaleX(0);
Top := ScaleY(202);
Width := ScaleX(209);
Height := ScaleY(13);
end;

FreeSpaceLabel := TLabel.Create(WizardForm);
with FreeSpaceLabel do
begin
Parent := WizardForm.SelectDirPage;
Left := ScaleX(0);
Top := ScaleY(220);
Width := ScaleX(209);
Height := ScaleY(13);
end;
WizardForm.DirEdit.OnChange := @GetFreeSpaceCaption;
WizardForm.DirEdit.Text := WizardForm.DirEdit.Text + #0;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID=wpSelectDir then begin
GetNeedSpaceCaption;
if FreeMB < NeedSize then
WizardForm.NextButton.Enabled:=False
end;
end;
И впредь лучше юзай Поиск или читай Справку, подобные вопросы каждые 10 страниц форума повторяются...

Tukash
02-01-2010, 12:21
A1EXXX
спасибо, сорри не знал что они такие распространенные!

A1EXXX
02-01-2010, 15:00
Inno Setup Compiler 5.3.6 (build 100102) Final (http://restools.hanzify.org/inno/InnoCompiler100102_English(7zip).zip) by Restools (http://restools.hanzify.org/)

JohnDes
03-01-2010, 15:14
Помогите соединить два скрипта.
Этот[Code]
const
Archives = '{src}\*.cab'; // укажите расположение архивов FreeArc; для внешних файлов строку в [Files] добавлять необязательно

PM_REMOVE = 1;
CP_ACP = 0; CP_UTF8 = 65001;
oneMb = 1048576;

type
#ifdef UNICODE ; если у вас ошибка на этой строке, то установите препроцессор или исправьте скрипт для вашей версии Inno Setup
#define A "W"
#else
#define A "A" ; точка входа в SetWindowText, {#A} меняется на A или W в зависимости от версии
PAnsiChar = PChar; // Required for Inno Setup 5.3.0 and higher. (требуется для Inno Setup версии 5.3.0 и ниже)
#endif
#if Ver < 84018176
AnsiString = String; // There is no need for this line in Inno Setup 5.2.4 and above (для Inno Setup версий 5.2.4 и выше эта строка не нужна)
#endif

TMyMsg = record
hwnd: HWND;
message: UINT;
wParam: Longint;
lParam: Longint;
time: DWORD;
pt: TPoint;
end;

TFreeArcCallback = function (what: PAnsiChar; int1, int2: Integer; str: PAnsiChar): Integer;
TArc = record Path: string; OrigSize: Integer; Size: Extended; end;

var
ExtractFile: TLabel;
lblExtractFileName: TLabel;
btnCancelUnpacking: TButton;
CancelCode, n, UnPackError, StartInstall: Integer;
Arcs: array of TArc;
msgError: string;
lastMb: Integer;
baseMb: Integer;
totalUncompressedSize: Integer; // total uncompressed size of archive data in mb
LastTimerEvent: DWORD;

Function MultiByteToWideChar(CodePage: UINT; dwFlags: DWORD; lpMultiByteStr: string; cbMultiByte: integer; lpWideCharStr: string; cchWideChar: integer): longint; external 'MultiByteToWideChar@kernel32.dll stdcall';
Function WideCharToMultiByte(CodePage: UINT; dwFlags: DWORD; lpWideCharStr: string; cchWideChar: integer; lpMultiByteStr: string; cbMultiByte: integer; lpDefaultChar: integer; lpUsedDefaultChar: integer): longint; external 'WideCharToMultiByte@kernel32.dll stdcall';

function PeekMessage(var lpMsg: TMyMsg; hWnd: HWND; wMsgFilterMin, wMsgFilterMax, wRemoveMsg: UINT): BOOL; external 'PeekMessageA@user32.dll stdcall';
function TranslateMessage(const lpMsg: TMyMsg): BOOL; external 'TranslateMessage@user32.dll stdcall';
function DispatchMessage(const lpMsg: TMyMsg): Longint; external 'DispatchMessageA@user32.dll stdcall';

Function OemToChar(lpszSrc, lpszDst: AnsiString): longint; external 'OemToCharA@user32.dll stdcall';
function GetWindowLong(hWnd, nIndex: Integer): Longint; external 'GetWindowLongA@user32 stdcall delayload';
function SetWindowText(hWnd: Longint; lpString: String): Longint; external 'SetWindowText{#A}@user32 stdcall delayload';

function GetTickCount: DWord; external 'GetTickCount@kernel32';
function WrapFreeArcCallback (callback: TFreeArcCallback; paramcount: integer):longword; external 'wrapcallback@files:innocallback.dll stdcall';
function FreeArcExtract (callback: longword; cmd1,cmd2,cmd3,cmd4,cmd5,cmd6,cmd7,cmd8,cmd9,cmd10: PAnsiChar): integer; external 'FreeArcExtract@files:unarc.dll cdecl';

procedure AppProcessMessage;
var
Msg: TMyMsg;
begin
while PeekMessage(Msg, 0, 0, 0, PM_REMOVE) do begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end;

// Перевод числа в строку с точностью 3 знака (%.3n) с округлением дробной части, если она есть
Function NumToStr(Float: Extended): String;
Begin
Result:= Format('%.3n', [Float]); StringChange(Result, ',', '.');
while ((Result[Length(Result)] = '0') or (Result[Length(Result)] = '.')) and (Length(Result) > 1) do
SetLength(Result, Length(Result)-1);
End;

function cm(Message: String): String; Begin Result:= ExpandConstant('{cm:'+ Message +'}') 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;

// Converts OEM encoded string into ANSI
// Преобразует OEM строку в ANSI кодировку
function OemToAnsiStr( strSource: AnsiString): AnsiString;
var
nRet : longint;
begin
SetLength( Result, Length( strSource ) );
nRet:= OemToChar( strSource, Result );
end;

// Converts ANSI encoded string into UTF-8
// Преобразует строку из ANSI в UTF-8 кодировку
function AnsiToUtf8( strSource: string ): string;
var
nRet : integer;
WideCharBuf: string;
MultiByteBuf: string;
begin
strSource:= strSource + chr(0);
SetLength( WideCharBuf, Length( strSource ) * 2 );
SetLength( MultiByteBuf, Length( strSource ) * 2 );

nRet:= MultiByteToWideChar( CP_ACP, 0, strSource, -1, WideCharBuf, Length(WideCharBuf) );
nRet:= WideCharToMultiByte( CP_UTF8, 0, WideCharBuf, -1, MultiByteBuf, Length(MultiByteBuf), 0, 0);

Result:= MultiByteBuf;
end;

// OnClick event function for btnCancel
procedure btnCancelUnpackingOnClick(Sender: TObject);
begin
if MsgBox( SetupMessage( msgExitSetupMessage ), mbInformation, MB_YESNO ) = IDYES then
CancelCode:= -127;
end;

var origsize: Integer;
// The callback function for getting info about FreeArc archive
function FreeArcInfoCallback (what: PAnsiChar; Mb, sizeArc: Integer; str: PAnsiChar): Integer;
begin
if string(what)='origsize' then origsize := Mb else
if string(what)='compsize' then else
if string(what)='total_files' then else
Result:= CancelCode;
end;

// Returns decompressed size of files in archive
function ArchiveOrigSize(arcname: string): Integer;
var
callback: longword;
Begin
callback:= WrapFreeArcCallback(@FreeArcInfoCallback,4); //FreeArcInfoCallback has 4 arguments
CancelCode:= 0;
AppProcessMessage;
try
// Pass the specified arguments to 'unarc.dll'
Result:= FreeArcExtract (callback, 'l', '--', AnsiToUtf8(arcname), '', '', '', '', '', '', '');
if CancelCode < 0 then Result:= CancelCode;
if Result >= 0 then Result:= origsize;
except
Result:= -63; // ArcFail
end;
end;

// Scans the specified folders for archives and add them to list
function FindArcs(dir: string): Extended;
var
FSR: TFindRec;
Begin
Result:= 0;
if FindFirst(ExpandConstant(dir), FSR) then begin
try
repeat
// Skip everything but the folders
if FSR.Attributes and FILE_ATTRIBUTE_DIRECTORY > 0 then CONTINUE;
n:= GetArrayLength(Arcs);
// Expand the folder list
SetArrayLength(Arcs, n +1);
Arcs[n].Path:= ExtractFilePath(ExpandConstant(dir)) + FSR.Name;
Arcs[n].Size:= Size64(FSR.SizeHigh, FSR.SizeLow);
Result:= Result + Arcs[n].Size;
Arcs[n].OrigSize := ArchiveOrigSize(Arcs[n].Path)
totalUncompressedSize := totalUncompressedSize + Arcs[n].OrigSize
until not FindNext(FSR);
finally
FindClose(FSR);
end;
end;
End;

// Sets the TaskBar title
Procedure SetTaskBarTitle(Title: String); var h: Integer;
Begin
h:= GetWindowLong(MainForm.Handle, -8); if h <> 0 then SetWindowText(h, Title);
End;

// Converts milliseconds to human-readable time
// Конвертирует милисекунды в человеко-читаемое изображение времени
Function TicksToTime(Ticks: DWord; h,m,s: String; detail: Boolean): String;
Begin
if detail {hh:mm:ss format} then
Result:= PADZ(IntToStr(Ticks/3600000), 2) +':'+ PADZ(IntToStr((Ticks/1000 - Ticks/1000/3600*3600)/60), 2) +':'+ PADZ(IntToStr(Ticks/1000 - Ticks/1000/60*60), 2)
else if Ticks/3600 >= 1000 {more than hour} then
Result:= IntToStr(Ticks/3600000) +h+' '+ PADZ(IntToStr((Ticks/1000 - Ticks/1000/3600*3600)/60), 2) +m
else if Ticks/60 >= 1000 {1..60 minutes} then
Result:= IntToStr(Ticks/60000) +m+' '+ PADZ(IntToStr(Ticks/1000 - Ticks/1000/60*60), 2) +s
else Result:= IntToStr(Ticks/1000) +s {less than one minute}
End;

// The main callback function for unpacking FreeArc archives
function FreeArcCallback (what: PAnsiChar; Mb, sizeArc: Integer; str: PAnsiChar): Integer;
var
percents, Remaining: Integer;
s: String;
begin
if GetTickCount - LastTimerEvent > 1000 then begin
// This code will be executed once each 1000 ms (этот код будет выполняться раз в 1000 миллисекунд)
// ....
// End of code executed by timer
LastTimerEvent := LastTimerEvent+1000;
end;

if string(what)='filename' then begin
// Update FileName label
lblExtractFileName.Caption:= FmtMessage( cm( 'Extracting' ), [OemToAnsiStr( str )] )
end else if (string(what)='write') and (totalUncompressedSize>0) and (Mb>lastMb) then begin
// Assign to Mb *total* amount of data extracted to the moment from all archives
lastMb := Mb;
Mb := baseMb+Mb;

// Update progress bar
WizardForm.ProgressGauge.Position:= Mb;

// Show how much megabytes/archives were processed up to the moment
percents:= (Mb*1000) div totalUncompressedSize;
s := FmtMessage(cm('ExtractedInfo'), [IntToStr(Mb), IntToStr(totalUncompressedSize)]);
if GetArrayLength(Arcs)>1 then
s := s + '. '+FmtMessage(cm('ArcInfo'), [IntToStr(n+1), IntToStr(GetArrayLength(Arcs))])
ExtractFile.Caption := s

// Calculate and show current percents
percents:= (Mb*1000) div totalUncompressedSize;
s:= FmtMessage(cm('AllProgress'), [Format('%.1n', [Abs(percents/10)])]);
if Mb > 0 then Remaining:= trunc((GetTickCount - StartInstall) * Abs((totalUncompressedSize - Mb)/Mb)) else Remaining:= 0;
if Remaining = 0 then SetTaskBarTitle(cm('ending')) else begin
s:= s + '. '+FmtMessage(cm('remains'), [TicksToTime(Remaining, cm('hour'), cm('min'), cm('sec'), false)])
SetTaskBarTitle(FmtMessage(cm('taskbar'), [IntToStr(percents/10), TicksToTime(Remaining, 'h', 'm', 's', false)]))
end;
WizardForm.FileNameLabel.Caption := s
end;
AppProcessMessage;
Result:= CancelCode;
end;

// Extracts all found archives
function UnPack(Archives: string): Integer;
var
totalCompressedSize: Extended;
callback: longword;
FreeMB, TotalMB: Cardinal;
begin
// Display 'Extracting FreeArc archive'
lblExtractFileName.Caption:= '';
lblExtractFileName.Show;
ExtractFile.caption:= cm('ArcTitle');
ExtractFile.Show;
// Show the 'Cancel unpacking' button and set it as default button
btnCancelUnpacking.Caption:= WizardForm.CancelButton.Caption;
btnCancelUnpacking.Show;
WizardForm.ActiveControl:= btnCancelUnpacking;
WizardForm.ProgressGauge.Position:= 0;
// Get the size of all archives
totalUncompressedSize := 0;
totalCompressedSize := FindArcs(Archives);
WizardForm.ProgressGauge.Max:= totalUncompressedSize;
// Other initializations
callback:= WrapFreeArcCallback(@FreeArcCallback,4); //FreeArcCallback has 4 arguments
StartInstall:= GetTickCount; {время начала распаковки}
LastTimerEvent:= GetTickCount;
baseMb:= 0

for n:= 0 to GetArrayLength(Arcs) -1 do
begin
lastMb := 0
CancelCode:= 0;
AppProcessMessage;
try
// Pass the specified arguments to 'unarc.dll'
Result:= FreeArcExtract (callback, 'x', '-o+', '-dp' + AnsiToUtf8( ExpandConstant('{app}') ), '--', AnsiToUtf8(Arcs[n].Path), '', '', '', '', '');
if CancelCode < 0 then Result:= CancelCode;
except
Result:= -63; // ArcFail
end;
baseMb:= baseMb+lastMb

// Error occured
if Result <> 0 then
begin
msgError:= FmtMessage(cm('ArcError'), [IntToStr(Result)]);
GetSpaceOnDisk(ExtractFileDrive(ExpandConstant('{app}')), True, FreeMB, TotalMB);
case Result of
-1: if FreeMB < 32 {Мб на диске} then msgError:= SetupMessage(msgDiskSpaceWarningTitle)
else msgError:= msgError + #13#10 + FmtMessage(cm('ArcBroken'), [ExtractFileName(Arcs[n].Path)]);
-127: msgError:= cm('ArcBreak'); //Cancel button
-63: msgError:= cm('ArcFail');
end;
// MsgBox(msgError, mbInformation, MB_OK); //сообщение показывается на странице завершения
Log(msgError);
Break; //прервать цикл распаковки
end;
end;
// Hide labels and button
WizardForm.FileNameLabel.Caption:= '';
lblExtractFileName.Hide;
ExtractFile.Hide;
btnCancelUnpacking.Hide;
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
begin
UnPackError:= UnPack(Archives)
if UnPackError = 0 then
SetTaskBarTitle(SetupMessage(msgSetupAppTitle))
else
begin
// Error occured, uninstall it then
Exec(ExpandConstant('{uninstallexe}'), '/SILENT','', sw_Hide, ewWaitUntilTerminated, n); //откат установки из-за ошибки unarc.dll
SetTaskBarTitle(SetupMessage(msgErrorTitle))
WizardForm.Caption:= SetupMessage(msgErrorTitle) +' - '+ cm('ArcBreak')
end;
end;
end;

// стандартный способ отката (не нужна CurPageChanged), но архивы распаковываются до извлечения файлов инсталлятора
// if CurStep = ssInstall then
// if UnPack(Archives) <> 0 then Abort;

Procedure CurPageChanged(CurPageID: Integer);
Begin
if (CurPageID = wpFinished) and (UnPackError <> 0) then
begin // Extraction was unsuccessful (распаковщик вернул ошибку)
// Show error message
WizardForm.FinishedLabel.Font.Color:= $0000C0; // red (красный)
WizardForm.FinishedLabel.Height:= WizardForm.FinishedLabel.Height * 2;
WizardForm.FinishedLabel.Caption:= SetupMessage(msgSetupAborted) + #13#10#13#10 + msgError;
end;
End;

procedure InitializeWizard();
begin
with WizardForm.ProgressGauge do
begin
// Create a label to show current FileName being extracted
lblExtractFileName:= TLabel.Create(WizardForm);
lblExtractFileName.parent:=WizardForm.InstallingPage;
lblExtractFileName.autosize:=false;
lblExtractFileName.Width:= Width;
lblExtractFileName.top:=Top + ScaleY(35);
lblExtractFileName.Caption:= '';
lblExtractFileName.Hide;

// Create a label to show percentage
ExtractFile:= TLabel.Create(WizardForm);
ExtractFile.parent:=WizardForm.InstallingPage;
ExtractFile.autosize:=false;
ExtractFile.Width:= Width;
ExtractFile.top:=lblExtractFileName.Top + ScaleY(16);
ExtractFile.caption:= '';
ExtractFile.Hide;
end;

// Create a 'Cancel unpacking' button and hide it for now.
btnCancelUnpacking:=TButton.create(WizardForm);
btnCancelUnpacking.Parent:= WizardForm;
btnCancelUnpacking.SetBounds(WizardForm.CancelButton.Left, WizardForm.CancelButton.top, WizardForm.CancelButton.Width, WizardForm.CancelButton.Height);
btnCancelUnpacking.OnClick:= @btnCancelUnpackingOnClick;
btnCancelUnpacking.Hide;
end;

И этот procedure InitializeWizard();
begin
//Выносим кнопку "Отмена" на передний план
WizardForm.CancelButton.BringToFront;
end;

procedure CurPageChanged(CurPageID: Integer);
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(0);
WizardForm.Top:=ScaleY(0);
{Внимание! Нижеописанные способы смещения работают только когда вставлено фоновое изображение или WindowVisible=yes}
{Выводит в правом верхнем углу экрана}
//WizardForm.Left:=ScaleX(MainForm.Width-420);
//WizardForm.Top:=ScaleY(MainForm.Left+20);

{Выводит снизу по центру экрана}
//WizardForm.Position:=poScreenCenter;
//WizardForm.Top:=ScaleY(MainForm.Height-170);

{Выводит в нижнем левом углу (как в Doom 3 Resurrection of Evil от 1C)}
//WizardForm.Left:=ScaleX(MainForm.Left+20);
//WizardForm.Top:=ScaleY(MainForm.Height-170);

{Выводит в нижнем правом углу}
//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);
end
if CurPageID=wpFinished
then
begin
WizardForm.Width:=502;{Размер окна по горизонтали}
WizardForm.Height:=392;{Размер окна по вертикали}
WizardForm.Position:=poScreenCenter; {Возврат в исходное состояние}
end
end;
Чтобы не было вот так http://i035.radikal.ru/1001/a6/dfb2498ad2d3t.jpg (http://radikal.ru/F/i035.radikal.ru/1001/a6/dfb2498ad2d3.png.html) и работала кнопка отмены
PS скажите что нужно сделать чтобы у bmp фон был прозрачный ?

Lancer2404
03-01-2010, 15:18
Не так давно писали мне скрипт использования ShellOperation.Так во не могу понять почему он не работает.


#include "J:\Worked Dir\Script\SHFileOperation.iss"

[Setup]
AppName=Tests gta pack
AppVerName=Test
DefaultDirName={pf}\WD
OutputDir=.
Compression=lzma/ultra
InternalCompressLevel=ultra
SolidCompression=yes

[Languages]
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"
[Files]
Source:D:\wd\w.txt; DestDir: "{app}"; Flags: ignoreversion recursesubdirs overwritereadonly
Source:D:\wd\ws.txt ;DestDir: "{app}\data"; Flags: ignoreversion recursesubdirs overwritereadonly


[Tasks]
Name: arc; Description: "Backup"

[Code]
var
Page: TInputDirWizardPage;

function ShouldSkipPage(PageID: Integer): Boolean;
begin
Result:= (PageID = Page.ID) and not IsTaskSelected('arc');
end;

procedure InitializeWizard();
begin
Page:= CreateInputDirPage(wpSelectTasks, 'Выберите папку бэкапа.',
'Куда вы засуните файлы бэкапа.Оттуда вы сможете восстановить свои файлы',
'Для продолжения нажмите далее.' + #10#13#10#13 +
'Если хотите выбрать другую папку щелкните Обзор.',
False, 'Backup');
Page.Add('');
Page.Values[0]:= ExpandConstant('{sd}\Backup');
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
if (CurStep = ssPreInstall) and IsTaskSelected('arc') then
CopyDir(ExpandConstant('{app}'), Page.Values[0]);
end;




© OSzone.net 2001-2012