PDA

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


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

tem000
02-05-2009, 01:31
Serega_, УРА!!! заработало пасибо огромное господа программеры за помощь!!! :laugh:

PS. Мдя, называется век живи - век учись!!!

BlackSelf
02-05-2009, 04:09
Serega_, хотел бы вернуться к своему вопросу по поводу фриарка.
Создается вот такой лог:

FreeArc 0.50 alpha (June 23 2008) extracting archive: archive.arc
Extracting 28 files, 1.878.921.539 bytes. Processed 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% 1.9% 2.5% 3.5% 4.5% 4.8% 5.5% 5.8% 6.1% 6.2% 6.4% 7.0% 7.9% 8.7% 8.9% 9.2% 9.8% 10.2% 10.3% 10.9% 11.6% 12.1% 12.6% 12.9% 12.9% 12.9% 12.9% 12.9% 12.9% 12.9% 12.9% 12.9% 12.9% 12.9% 12.9% 12.9% 12.9% 12.9% 12.9% 12.9% 14.1% 14.3% 15.1% 15.1% 15.5% 15.7% 15.8% 16.5% 17.5% 17.8% 18.4% 18.9% 19.2% 19.6% 20.2% 20.5% 21.6% 21.9% 22.9% 23.3% 23.8% 24.1% 24.2% 24.9% 25.1% 25.8% 26.3% 26.8% 27.2% 27.6% 27.8% 28.4% 28.5% 29.0% 29.0% 29.0% 29.0% 29.0% 29.0% 29.0% 29.0% 29.0% 29.0% 29.0% 29.0% 29.0% 29.0% 29.0% 29.0% 29.0% 29.0% 29.0% 29.0% 29.0% 29.0% 30.2% 30.6% 32.5% 33.4% 33.9% 35.0% 35.5% 36.5% 37.1% 37.5% 37.9% 38.6% 38.8% 39.4% 40.1% 40.6% 41.0% 41.6% 42.0% 42.4% 42.4% 42.4% 42.4% 42.4% 42.4% 42.4% 42.4% 42.4% 42.4% 42.4% 42.4% 42.4% 42.4% 42.4% 42.4% 42.4% 42.4% 42.4% 42.4% 42.4% 42.4% 42.4% 42.4% 42.4% 42.4% 43.2% 44.6% 45.3% 46.3% 46.7% 47.3% 48.5% 48.9% 49.6% 50.1% 50.8% 51.3% 51.7% 52.4% 53.3% 53.3% 54.6% 54.9% 54.9% 54.9% 54.9% 54.9% 54.9% 54.9% 54.9% 54.9% 54.9% 54.9% 54.9% 54.9% 54.9% 54.9% 54.9% 54.9% 54.9% 55.7% 56.9% 58.0% 59.0% 59.6% 60.5% 61.1% 61.3% 61.9% 62.3% 62.9% 63.6% 64.2% 65.1% 65.4% 66.0% 66.0% 66.0% 66.0% 66.0% 66.0% 66.0% 66.0% 66.0% 66.0% 66.0% 66.0% 66.0% 66.0% 66.0% 66.0% 67.1% 67.6% 68.5% 68.9% 69.8% 70.3% 71.4% 72.2% 72.6% 73.2% 74.0% 74.6% 75.4% 75.9% 76.8% 77.2% 77.6% 77.6% 77.6% 77.6% 77.6% 77.6% 77.6% 77.6% 77.6% 77.6% 77.6% 77.6% 77.6% 77.6% 77.6% 77.6% 77.6% 77.6% 77.6% 77.6% 77.6% 77.6% 78.2% 79.9% 80.0% 80.3% 81.1% 82.3% 83.0% 83.2% 83.4% 83.5% 84.6% 85.4% 86.5% 86.9% 86.9% 87.1% 87.7% 87.9% 88.1% 88.1% 89.2% 89.2% 89.2% 89.2% 89.2% 89.2% 89.2% 89.2% 89.2% 89.2% 89.2% 89.2% 89.2% 89.2% 89.2% 89.2% 89.2% 89.2% 89.2% 89.2% 89.2% 89.2% 89.2% 89.2% 89.2% 89.2% 89.2% 89.2% 90.0% 90.6% 90.8% 92.1% 92.9% 93.9% 94.6% 95.5% 96.5% 96.8% 97.4% 97.6% 98.3% 99.5% 99.6% 99.6% 99.6% 99.6% 99.7%

Extracted 28 files, 529.994.251 => 1.878.921.539 bytes. Ratio 28.2%
Extraction time 53.06 secs, speed 35.414 kB/s. Total 160.86 secs
All OK
Как заставить инсталл обращаться к этому файлу, считывать оттуда проценты и выводить их на прогресс-бар?
У меня есть небольшой кусок нужного мне кода, но я не знаю, как довести его до ума.

procent$=StrFromFile(file$,1,-1)
position=LEN(procent$)
position$=StrGet(procent$,position)
If (position$='%') Then
procent_bar$=''
position=position-5
procent_bar$=procent_bar$+StrGet(procent$,position)
position=position+1
procent_bar$=procent_bar$+StrGet(procent$,position)
position=position+1
procent_bar$=procent_bar$+StrGet(procent$,position)
position=position+1
procent_bar$=procent_bar$+StrGet(procent$,position)
position=position+1
procent_bar$=procent_bar$+StrGet(procent$,position)
position=position+1
procent_bar$=procent_bar$+StrGet(procent$,position)
newbar=VAL(procent_bar$)
shownprogress=INT(newbar)
newbar=newbar+diskscount
procent$=CHAR(newbar)

Serega
02-05-2009, 14:08
BlackSelf, сразу несколько вопросов.
Вы говорите создаётся лог, когда? В процессе распаковки или вы его распаковываете из инсталлятора во время установки?

Видите ли, если можно было бы определить скорость распаковки архива на машине конкретного пользователя до распаковки основного архива. Скажем во время запуска инсталлятора, запускаем небольшой тестовый архив, с сохранением лога, из которого получаем скорость распаковки архива на данной машине, тогда можно прикинуть приблизительную скорость распаковки основного архива, высчитав пропорцией...
Уже в соответствии с этим двигать прогрессбар…

BlackSelf
02-05-2009, 14:15
Serega_, лог создается в процессе распаковки архива с постоянным обновлением информации о процентах. Поэтому хотелось бы, чтобы инно постоянно обращался к этому файлу и брал оттуда данные о процентах.

Serega
02-05-2009, 14:21
BlackSelf, где создаётся, в {app}, т.е. в папке куда устанавливаем программу?

BlackSelf
02-05-2009, 14:25
Serega_, в принципе, можно и в {app}, можно и в {tmp}. Допустим, что в {app}.

Serega
03-05-2009, 08:33
BlackSelf, напишите пример команд, упаковки и распаковки архива с ведением лога. Скачал FreeArc, а чего-то разобраться не могу, как вызвать сохранение лога...
Наброски по движению прогрессбара есть, нужно протестировать работоспособность кода...

Unsane
03-05-2009, 11:38
Доброе время суток.
В [Components] есть несколько пунктов с флагом exclusive, отвечающих за язык устанавливаемого приложения. Можно ли автоматом отмечать пункт, язык которого совпадает с языком установщика(выбирается при запуске)?

Serega
03-05-2009, 12:31
несколько пунктов с флагом exclusive, отвечающих за язык устанавливаемого приложения. Можно ли автоматом отмечать пункт, язык которого совпадает с языком установщика(выбирается при запуске)? »[Setup]
AppName=My Program
AppVerName=My Program v 1.5
DefaultDirName={pf}\My Program
OutputDir=.
Compression=lzma/ultra
InternalCompressLevel=ultra
SolidCompression=yes
ComponentsListTVStyle=true

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

[Types]
Name: full; Description: Полная установка
Name: custom; Description: Выборочная установка; Flags: iscustom

[Components]
Name: a; Description: Моя программа™; Types: full custom
Name: a\a; Description: Руководство пользователя; Types: full
Name: a\a\a; Description: Русский; Languages: rus; Flags: exclusive
Name: a\a\b; Description: English; Languages: eng; Flags: exclusive
Name: a\b; Description: Справка; Types: full

[Files]
Source: compiler:Examples\MyProg.exe; DestDir: {app}; Components: a
Source: compiler:Examples\Readme-ru.txt; DestDir: {app}; Components: a\a\a
Source: compiler:Examples\Readme-en.txt; DestDir: {app}; Components: a\a\b
Source: compiler:Examples\MyProg.chm; DestDir: {app}; Components: a\b

Unsane
03-05-2009, 12:56
Serega_, это немного не то.. При выборе русского языка, пункт "Руководство пользователя\English" не будет показан пользователю, а надо, чтобы были показаны все языки, но "галка" стояла на том, который выбран как язык инсталлятора..

Serega
03-05-2009, 14:41
Unsane, если привязываться к языку, то будет именно так, что другой пункт языка не будет отображаться...

BlackSelf
04-05-2009, 05:30
Serega_, при создании архива лог не нужен, но всё же:
Упаковка:
arc create archive -mx -ld=192m folder\* >log.txt
Распаковка:
arc x archive.arc -y -s2 -dp >log.txt
Лог будет создаваться рядом с arc.exe

p3rf3ct1c
04-05-2009, 19:38
Здравствуйте! Можете помоч, как сделать вот такое?
http://pic.ipicture.ru/uploads/090504/SVpZ71s0rm.jpg
Типо это обязательно для установки. Чтобы нельзя было снять галочку.

boss911
04-05-2009, 20:35
Чтобы нельзя было снять галочку. »

[Tasks]
Name: DirectXUpd; Description: Обновить DirectX; GroupDescription: Системные задачи:

[_Code]
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpSelectTasks then
WizardForm.TasksList.ItemEnabled[X]:= False;
end;
ItemEnabled[X] - здесь нужно указать цифру (см. ниже), порядковый номер строки на странице выбора задач (TasksList), отсчет идет сверху и начинается с 0 (нуля). Судя, по-вашему скриншоту, порядковый номер чекбокса, который нужно заблокировать, это 4.

p3rf3ct1c
04-05-2009, 21:29
Код:
[Tasks]
Name: DirectXUpd; Description: Обновить DirectX; GroupDescription: Системные задачи:
[_Code]
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpSelectTasks then
WizardForm.TasksList.ItemEnabled[X]:= False;
end;
ItemEnabled[X] - здесь нужно указать цифру (см. ниже), порядковый номер строки на странице выбора задач (TasksList), отсчет идет сверху и начинается с 0 (нуля). Судя, по-вашему скриншоту, порядковый номер чекбокса, который нужно заблокировать, это 4. »
Спасибо вам! Все получилось.
Можно еще вопрос? Можете подсказать как правильно склеивать коды? Например вот


procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpSelectTasks then
WizardForm.TasksList.ItemEnabled[X]:= False;
end;


который вы мне написали, и этот


var n: Integer; FreeMB, TotalMB: Cardinal; VolumeName, FileSystemName: String; VolumeSerialNo, MaxComponentLength, FileSystemFlags: Longint; ListBox: TListBox; StartMenuTreeView: TStartMenuFolderTreeView;

const oneMB= 1024*1024;
function GetLogicalDrives: DWord; external 'GetLogicalDrives@kernel32.dll stdcall';
function GetDriveType(nDrive: String): Longint; external 'GetDriveTypeA@kernel32.dll stdcall';
function GetVolumeInformation(PathName,VolumeName: PChar; VolumeNameSize,VolumeSerialNumber,MaxComponentLength,FileSystemFlags: Longint; FileSystemName: PChar; FileSystemNameSize: Longint): Longint; external 'GetVolumeInformationA@kernel32.dll stdcall';
function MessageBox(hWnd: Integer; lpText, lpCaption: String; uType: Cardinal): Integer; external 'MessageBoxA@user32.dll stdcall';

Function ByteOrTB(Bytes: Extended; noMB: Boolean): String; { Ïåðåâîä ÷èñëà â çíà÷åíèå áò/Êá/Ìá/Ãá/Òá (äî 3õ çíàêîâ ïîñëå çàïÿòîé)}
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 CutString(String: String; MaxLength: Longint): String; { Îáðåçàòü ñòðîêó äî çàäàííîãî êîë-âà ñèìâîëîâ}
Begin
if Length(String) > MaxLength then Result:= Copy(String, 1, 6) +'...'+ Copy(String, Length(String) - MaxLength +9, MaxLength)
else Result:= String;
End;

Procedure GetDiskInfo(Disk: String);
Begin
FileSystemName:= StringOfChar(' ', 32); VolumeName:= StringOfChar(' ', 256);
GetVolumeInformation(Disk, VolumeName, 255, VolumeSerialNo, MaxComponentLength, FileSystemFlags, FileSystemName, 31);
FileSystemName:= DelSp(FileSystemName); VolumeName:= DelSp(VolumeName); if VolumeName='' then VolumeName:='áåç ìåòêè';
End;

Procedure ListBoxRefresh; var FreeB, TotalB: Cardinal; Path, String: string; Begin
ListBox.Items.Clear
for n:= 1 to 31 do // äèñê 'À' ïðîïóñòèòü
if (GetLogicalDrives and (1 shl n)) > 0 then
if (GetDriveType(Chr(ord('A') + n) +':\') = 2) or (GetDriveType(Chr(ord('A') + n) +':\') = 3) then
if GetSpaceOnDisk(Chr(ord('A') + n) +':\', True, FreeMB, TotalMB) then ListBox.Items.Add(Chr(ord('A') + n) +':');
for n:= 0 to ListBox.Items.Count -1 do begin
Path:= Copy(ListBox.Items[n],1,2) +'\' { åñëè â íàêîïèòåëå íåò äèñêà, ïðîïóñòèòü îáíîâëåíèå }
if GetSpaceOnDisk(Path, False, FreeB, TotalB) and GetSpaceOnDisk(Path, True, FreeMB, TotalMB) then begin GetDiskInfo(Path);
if FreeB >= $7FFFFFFF then String:= PadL(ByteOrTB(FreeMB*oneMB, true),10) else String:= PadL(ByteOrTB(FreeB, true),10);
if TotalB >= $7FFFFFFF then begin TotalB:= TotalMB; FreeB:= FreeMB; String:= PadL(ByteOrTB(TotalMB*oneMB, true),11) +' âñåãî| '+ String end else String:= PadL(ByteOrTB(TotalB, true),11) +' âñåãî| '+ String;
ListBox.Items[n]:= Copy(Path,1,2) + String + PadL(FloatToStr(round(FreeB/TotalB*100)),3)+ '% ñâîá|'+ PadL(FileSystemName,5)+ '| '+ CutString(VolumeName,9); end; end;
End;

Procedure ObjectOnClick(Sender: TObject); Begin
Case TObject(Sender) of
ListBox: for n:= 0 to ListBox.Items.Count-1 do if ListBox.Selected[n] then WizardForm.DirEdit.Text:= Copy(ListBox.Items[n],1,1) +Copy(WizardForm.DirEdit.Text, 2, Length(WizardForm.DirEdit.Text))
StartMenuTreeView: if StartMenuTreeView.Directory <> '' then WizardForm.GroupEdit.Text:= StartMenuTreeView.Directory else WizardForm.GroupEdit.Text:= '{#SetupSetting("DefaultGroupName")}'
WizardForm.NoIconsCheck: begin WizardForm.GroupEdit.Enabled:= not(WizardForm.GroupEdit.Enabled); StartMenuTreeView.Enabled:= WizardForm.GroupEdit.Enabled; WizardForm.GroupBrowseButton.Enabled:= WizardForm.GroupEdit.Enabled end;
end; End;

Function NextButtonClick(CurPageID: Integer): Boolean; Begin
Result:= True
if (CurPageID = wpSelectDir) and (Pos(Uppercase(ExpandConstant('{win}')), Uppercase(ExpandConstant('{app}'))) > 0) then Result:= MessageBox(StrToInt(ExpandConstant('{wizardhwnd}')), ExpandConstant('{cm:SysDirSelect}'), 'Óñòàíîâêà â ñèñòåìíóþ ïàïêó', MB_YESNO or $30) = idYes;
End;

Procedure CurPageChanged(CurPageID: Integer);
Begin
if CurPageID = wpSelectDir then ListBoxRefresh
End;

Procedure InitializeWizard;
Begin
ListBox:= TListBox.Create(WizardForm)
ListBox.SetBounds(WizardForm.DirEdit.Left, WizardForm.DirEdit.Top + WizardForm.DirEdit.Height + 8, WizardForm.DirBrowseButton.Left + WizardForm.DirBrowseButton.Width - WizardForm.DirEdit.Left, WizardForm.DiskSpaceLabel.Top - (WizardForm.DirEdit.Top + WizardForm.DirEdit.Height + 12))
ListBox.Font.Size:= 9
ListBox.Font.Style:= [fsBold]
ListBox.Font.Name:= 'Courier New';
ListBox.OnClick:= @ObjectOnClick;
ListBox.Parent:= WizardForm.SelectDirPage;
WizardForm.NoIconsCheck.SetBounds(WizardForm.DiskSpaceLabel.Left + 96, WizardForm.DiskSpaceLabel.Top + 1, WizardForm.NoIconsCheck.Width, WizardForm.NoIconsCheck.Height)
WizardForm.NoIconsCheck.OnClick:= @ObjectOnClick
WizardForm.NoIconsCheck.Parent:= WizardForm.SelectProgramGroupPage
WizardForm.NoIconsCheck.Show
StartMenuTreeView:= TStartMenuFolderTreeView.Create(WizardForm)
StartMenuTreeView.SetPaths(ExpandConstant('{userprograms}'), ExpandConstant('{commonprograms}'), ExpandConstant('{userstartup}'), ExpandConstant('{commonstartup}'));
StartMenuTreeView.SetBounds(ListBox.Left, ListBox.Top, ListBox.Width, ListBox.Height)
StartMenuTreeView.Parent:= WizardForm.SelectProgramGroupPage
StartMenuTreeView.Cursor:= crHand
StartMenuTreeView.OnChange:=@ObjectOnClick
End;


А то у меня выдает ошибку - Duplicate identifer 'CURPAGECHANGED' или когда пытаюсь склеить другие коды, ошибка Duplicate identifer 'InitializeWizard' или другие ошибки.

Serega
04-05-2009, 21:30
Скрипт для отображения процесса распаковки внешних FreeArc архивов во втором прогрессбаре, необходима расширенная версия от Restools:
; Скрипт для отображения процесса распаковки внешних FreeArc архивов во втором прогрессбаре
; Рядом с архивом необходимо расположить архивы и Arc.exe
; Для нормальной работы необходима расширенная версия Inno Setup от Restools http://restools.hanzify.org/
; Отдельное спасибо BlackSelf, http://www.forum.oszone.ru/member.php?userid=147308, за подсказанную идею... :)
; Автор скрипта: Serega, http://forum.oszone.net/member.php?userid=88670

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

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

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

[Code]
var
ProgressLabel: TLabel;
ProgressBar: TNewProgressBar;

procedure ParserLog;
var
in_File, out_File, S, S1, S2: string;
i, j, n: Integer;
begin
n:= 0;
in_File := ExpandConstant('{tmp}\in_log');
out_File := ExpandConstant('{tmp}\out_log');
ProgressBar.Position:= 0;
ProgressBar.Show;
ProgressLabel.Show;
// если файла нет, то подождём... ;)
if FileExists(in_File) = False then
repeat
Application.ProcessMessages; // необходима расширенная версия от Restools
n:= n + 1;
Sleep(500); // ждём полсекунды и повторяем цикл
until (FileExists(in_File) = True) or (n = 10); // максимально повторяем цикл 10 раз, что составит 5 секунд...
// если всё же файла нет, то выходим
if FileExists(in_File) = False then Exit;
// если файл существует, то обрабатываем его
repeat
FileCopy(in_File, out_File, False); // копируем файл, чтоб можно было открыть out_File для чтения
LoadStringFromFile(out_File, S); // если попытаться загрузить in_File, то ничего не выйдет, пока в него пишет Arc.exe...
Application.ProcessMessages; // необходима расширенная версия от Restools
if Pos('%', S) > 0 then begin
S1:= Copy(S, Length(S) - 4, (Length(S) - 2) - (Length(S) - 4));
S2:= Copy(S, Length(S) - 4, Length(S) - (Length(S) - 5));
StringChange(S1, ' ', ''); // удаляем пробелы
for i:= 0 to 100 do if S1 = IntToStr(i) then begin
j:= StrToInt(S1);
ProgressBar.Position := j;
StringChange(S2, ' ', '');
ProgressLabel.Caption:= S2;
Application.ProcessMessages; // необходима расширенная версия от Restools
end;
end;
until (Pos('Extracted', S) or Pos('ERROR', S)) > 0;
ProgressBar.Position:= 100;
end;

procedure UnpackArc(archive_Name, archive_Path: string);
var
res: Integer;
begin
if FileExists(ExpandConstant('{tmp}\in_log')) then DelayDeleteFile(ExpandConstant('{tmp}\in_log'),8);
// запускаем Arc.exe... ;)
Exec('cmd.exe', '/C arc.exe x ' + archive_Name + ' -y -dp' + archive_Path + ' >' +
AddQuotes(ExpandConstant('{tmp}\in_log')), ExpandConstant('{src}'), SW_HIDE, ewNoWait, res);
WizardForm.StatusLabel.Caption:= 'Распаковка архива ' + ExtractFileName(archive_Name) + ', ждите...';
ParserLog; // обрабатываем лог файл
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then begin
WizardForm.CancelButton.Enabled:= False; // отключаем кнопку 'Отмена'
// AddQuotes - добавляет двойные кавычки в начало и конец строки...
UnpackArc(AddQuotes(ExpandConstant('{src}\Project.arc')), // расположение 1-го архива
AddQuotes(ExpandConstant('{app}\Archive1'))); // место распаковки 1-го архива
UnpackArc(AddQuotes(ExpandConstant('{src}\Project.arc')), // расположение 2-го архива
AddQuotes(ExpandConstant('{app}\Archive2'))); // место распаковки 2-го архива
WizardForm.StatusLabel.Caption:= WizardForm.StatusLabel.Caption;
end;
end;

procedure InitializeWizard;
begin
// второй прогрессбар
ProgressBar := TNewProgressBar.Create(WizardForm);
with ProgressBar do begin
Left := WizardForm.ProgressGauge.Left;
Top := WizardForm.ProgressGauge.Top + ScaleX(30);
Width := WizardForm.ProgressGauge.Width;
Height := WizardForm.ProgressGauge.Height;
Parent := WizardForm.InstallingPage;
Hide;
end;
// создаём Label для отображения процентов
ProgressLabel := TLabel.Create(WizardForm);
with ProgressLabel do begin
Left := ProgressBar.Left;
Top := ProgressBar.Top + ProgressBar.Height + ScaleX(5);
AutoSize:= True;
Caption:= '0%';
Parent := WizardForm.InstallingPage;
Transparent:= True;
Font.Color:= clDefault;
Hide;
end;
end;



1. Как сделать чтоб во время установки, архив копировался во временную папку %temp% и от туда распаковывался, т.е. использовать не внешний архив, а упакованный внутри инсталлятора?
Нужно добавить в скрипт секцию [Files] и исправить процедуру CurStepChanged:

..........................
[Files]
Source: Arc.exe; Flags: dontcopy
Source: Project.arc; Flags: dontcopy
..........................
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then begin
ExtractTemporaryFile('Arc.exe'); // извлекаем в {tmp} Arc.exe
WizardForm.StatusLabel.Caption:= 'Извлечение архива, ждите...';
ExtractTemporaryFile('Project.arc'); // извлекаем в {tmp} Project.arc

patch_Arc:= AddQuotes(ExpandConstant('{tmp}\Arc.exe')); // расположение Arc.exe
UnpackArc(AddQuotes(ExpandConstant('{tmp}\Project.arc')), // расположение архива
AddQuotes(ExpandConstant('{app}'))); // место распаковки архива
// AddQuotes - добавляет двойные кавычки в начало и конец строки...
end;
end;
..........................

p3rf3ct1c
04-05-2009, 21:51
Serega_,
Исправил.

Serega
04-05-2009, 21:57
p3rf3ct1c, var n: Integer; FreeMB, TotalMB: Cardinal; VolumeName, FileSystemName: String; VolumeSerialNo, MaxComponentLength, FileSystemFlags: Longint; ListBox: TListBox; StartMenuTreeView: TStartMenuFolderTreeView;

const oneMB= 1024*1024;
function GetLogicalDrives: DWord; external 'GetLogicalDrives@kernel32.dll stdcall';
function GetDriveType(nDrive: String): Longint; external 'GetDriveTypeA@kernel32.dll stdcall';
function GetVolumeInformation(PathName,VolumeName: PChar; VolumeNameSize,VolumeSerialNumber,MaxComponentLength,FileSystemFlags: Longint; FileSystemName: PChar; FileSystemNameSize: Longint): Longint; external 'GetVolumeInformationA@kernel32.dll stdcall';
function MessageBox(hWnd: Integer; lpText, lpCaption: String; uType: Cardinal): Integer; external 'MessageBoxA@user32.dll stdcall';

Function ByteOrTB(Bytes: Extended; noMB: Boolean): String; { Ia?aaia ?enea a cia?aiea ao/Ea/Ia/Aa/Oa (ai 3o ciaeia iinea caiyoie)}
Begin
if not noMB then Result:= FloatToStr(Int(Bytes)) +' Ia' else
if Bytes < 1024 then Result:= FloatToStr(Int(Bytes)) +' Ao' else
if Bytes/1024 < 1024 then Result:= FloatToStr(round((Bytes/1024)*10)/10) +' Ea' else
If Bytes/oneMB < 1024 then Result:= FloatToStr(round(Bytes/oneMB*100)/100) +' Ia' else
If Bytes/oneMB/1000 < 1024 then Result:= FloatToStr(round(Bytes/oneMB/1024*1000)/1000) +' Aa' else
Result:= FloatToStr(round(Bytes/oneMB/oneMB*1000)/1000) +' Oa'
StringChange(Result, ',', '.')
End;

Function DelSP(String: String): String; { Oaaeaiea ia?aeuiuo, eiia?iuo e iiaoi?iuo i?iaaeia }
Begin while (Pos(' ', String) > 0) do Delete(String, Pos(' ', String), 1); Result:= Trim(String); End;

Function CutString(String: String; MaxLength: Longint): String; { Ia?acaou no?ieo ai caaaiiiai eie-aa neiaieia}
Begin
if Length(String) > MaxLength then Result:= Copy(String, 1, 6) +'...'+ Copy(String, Length(String) - MaxLength +9, MaxLength)
else Result:= String;
End;

Procedure GetDiskInfo(Disk: String);
Begin
FileSystemName:= StringOfChar(' ', 32); VolumeName:= StringOfChar(' ', 256);
GetVolumeInformation(Disk, VolumeName, 255, VolumeSerialNo, MaxComponentLength, FileSystemFlags, FileSystemName, 31);
FileSystemName:= DelSp(FileSystemName); VolumeName:= DelSp(VolumeName); if VolumeName='' then VolumeName:='aac iaoee';
End;

Procedure ListBoxRefresh; var FreeB, TotalB: Cardinal; Path, String: string; Begin
ListBox.Items.Clear
for n:= 1 to 31 do // aene 'A' i?iionoeou
if (GetLogicalDrives and (1 shl n)) > 0 then
if (GetDriveType(Chr(ord('A') + n) +':\') = 2) or (GetDriveType(Chr(ord('A') + n) +':\') = 3) then
if GetSpaceOnDisk(Chr(ord('A') + n) +':\', True, FreeMB, TotalMB) then ListBox.Items.Add(Chr(ord('A') + n) +':');
for n:= 0 to ListBox.Items.Count -1 do begin
Path:= Copy(ListBox.Items[n],1,2) +'\' { anee a iaeiieoaea iao aenea, i?iionoeou iaiiaeaiea }
if GetSpaceOnDisk(Path, False, FreeB, TotalB) and GetSpaceOnDisk(Path, True, FreeMB, TotalMB) then begin GetDiskInfo(Path);
if FreeB >= $7FFFFFFF then String:= PadL(ByteOrTB(FreeMB*oneMB, true),10) else String:= PadL(ByteOrTB(FreeB, true),10);
if TotalB >= $7FFFFFFF then begin TotalB:= TotalMB; FreeB:= FreeMB; String:= PadL(ByteOrTB(TotalMB*oneMB, true),11) +' anaai| '+ String end else String:= PadL(ByteOrTB(TotalB, true),11) +' anaai| '+ String;
ListBox.Items[n]:= Copy(Path,1,2) + String + PadL(FloatToStr(round(FreeB/TotalB*100)),3)+ '% naia|'+ PadL(FileSystemName,5)+ '| '+ CutString(VolumeName,9); end; end;
End;

Procedure ObjectOnClick(Sender: TObject); Begin
Case TObject(Sender) of
ListBox: for n:= 0 to ListBox.Items.Count-1 do if ListBox.Selected[n] then WizardForm.DirEdit.Text:= Copy(ListBox.Items[n],1,1) +Copy(WizardForm.DirEdit.Text, 2, Length(WizardForm.DirEdit.Text))
StartMenuTreeView: if StartMenuTreeView.Directory <> '' then WizardForm.GroupEdit.Text:= StartMenuTreeView.Directory else WizardForm.GroupEdit.Text:= '{#SetupSetting("DefaultGroupName")}'
WizardForm.NoIconsCheck: begin WizardForm.GroupEdit.Enabled:= not(WizardForm.GroupEdit.Enabled); StartMenuTreeView.Enabled:= WizardForm.GroupEdit.Enabled; WizardForm.GroupBrowseButton.Enabled:= WizardForm.GroupEdit.Enabled end;
end; End;

Function NextButtonClick(CurPageID: Integer): Boolean;
Begin
Result:= True
if (CurPageID = wpSelectDir) and (Pos(Uppercase(ExpandConstant('{win}')), Uppercase(ExpandConstant('{app}'))) > 0) then Result:= MessageBox(StrToInt(ExpandConstant('{wizardhwnd}')), ExpandConstant('{cm:SysDirSelect}'), 'Onoaiiaea a nenoaiio? iaieo', MB_YESNO or $30) = idYes;
End;

Procedure CurPageChanged(CurPageID: Integer);
Begin
if CurPageID = wpSelectDir then ListBoxRefresh;
if CurPageID = wpSelectTasks then WizardForm.TasksList.ItemEnabled[X]:= False;
End;

Procedure InitializeWizard;
Begin
ListBox:= TListBox.Create(WizardForm)
ListBox.SetBounds(WizardForm.DirEdit.Left, WizardForm.DirEdit.Top + WizardForm.DirEdit.Height + 8, WizardForm.DirBrowseButton.Left + WizardForm.DirBrowseButton.Width - WizardForm.DirEdit.Left, WizardForm.DiskSpaceLabel.Top - (WizardForm.DirEdit.Top + WizardForm.DirEdit.Height + 12))
ListBox.Font.Size:= 9
ListBox.Font.Style:= [fsBold]
ListBox.Font.Name:= 'Courier New';
ListBox.OnClick:= @ObjectOnClick;
ListBox.Parent:= WizardForm.SelectDirPage;
WizardForm.NoIconsCheck.SetBounds(WizardForm.DiskSpaceLabel.Left + 96, WizardForm.DiskSpaceLabel.Top + 1, WizardForm.NoIconsCheck.Width, WizardForm.NoIconsCheck.Height)
WizardForm.NoIconsCheck.OnClick:= @ObjectOnClick
WizardForm.NoIconsCheck.Parent:= WizardForm.SelectProgramGroupPage
WizardForm.NoIconsCheck.Show
StartMenuTreeView:= TStartMenuFolderTreeView.Create(WizardForm)
StartMenuTreeView.SetPaths(ExpandConstant('{userprograms}'), ExpandConstant('{commonprograms}'), ExpandConstant('{userstartup}'), ExpandConstant('{commonstartup}'));
StartMenuTreeView.SetBounds(ListBox.Left, ListBox.Top, ListBox.Width, ListBox.Height)
StartMenuTreeView.Parent:= WizardForm.SelectProgramGroupPage
StartMenuTreeView.Cursor:= crHand
StartMenuTreeView.OnChange:=@ObjectOnClick
End;

p3rf3ct1c
04-05-2009, 22:07
Serega_,
Спасибо!

Raf-9600
05-05-2009, 00:05
Ктониь можеть объединить эти коды?
[Code]
var n: Integer; FreeMB, TotalMB: Cardinal; VolumeName, FileSystemName: String; VolumeSerialNo, MaxComponentLength, FileSystemFlags: Longint; ListBox: TListBox; StartMenuTreeView: TStartMenuFolderTreeView;

const oneMB= 1024*1024;
function GetLogicalDrives: DWord; external 'GetLogicalDrives@kernel32.dll stdcall';
function GetDriveType(nDrive: String): Longint; external 'GetDriveTypeA@kernel32.dll stdcall';
function GetVolumeInformation(PathName,VolumeName: PChar; VolumeNameSize,VolumeSerialNumber,MaxComponentLength,FileSystemFlags: Longint; FileSystemName: PChar; FileSystemNameSize: Longint): Longint; external 'GetVolumeInformationA@kernel32.dll stdcall';
function MessageBox(hWnd: Integer; lpText, lpCaption: String; uType: Cardinal): Integer; external 'MessageBoxA@user32.dll stdcall';

Function ByteOrTB(Bytes: Extended; noMB: Boolean): String; { Перевод числа в значение бт/Кб/Мб/Гб/Тб (до 3х знаков после запятой)}
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 CutString(String: String; MaxLength: Longint): String; { Обрезать строку до заданного кол-ва символов}
Begin
if Length(String) > MaxLength then Result:= Copy(String, 1, 6) +'...'+ Copy(String, Length(String) - MaxLength +9, MaxLength)
else Result:= String;
End;

Procedure GetDiskInfo(Disk: String);
Begin
FileSystemName:= StringOfChar(' ', 32); VolumeName:= StringOfChar(' ', 256);
GetVolumeInformation(Disk, VolumeName, 255, VolumeSerialNo, MaxComponentLength, FileSystemFlags, FileSystemName, 31);
FileSystemName:= DelSp(FileSystemName); VolumeName:= DelSp(VolumeName); if VolumeName='' then VolumeName:='без метки';
End;

Procedure ListBoxRefresh; var FreeB, TotalB: Cardinal; Path, String: string; Begin
ListBox.Items.Clear
for n:= 1 to 31 do // диск 'А' пропустить
if (GetLogicalDrives and (1 shl n)) > 0 then
if (GetDriveType(Chr(ord('A') + n) +':\') = 2) or (GetDriveType(Chr(ord('A') + n) +':\') = 3) then
if GetSpaceOnDisk(Chr(ord('A') + n) +':\', True, FreeMB, TotalMB) then ListBox.Items.Add(Chr(ord('A') + n) +':');
for n:= 0 to ListBox.Items.Count -1 do begin
Path:= Copy(ListBox.Items[n],1,2) +'\' { если в накопителе нет диска, пропустить обновление }
if GetSpaceOnDisk(Path, False, FreeB, TotalB) and GetSpaceOnDisk(Path, True, FreeMB, TotalMB) then begin GetDiskInfo(Path);
if FreeB >= $7FFFFFFF then String:= PadL(ByteOrTB(FreeMB*oneMB, true),10) else String:= PadL(ByteOrTB(FreeB, true),10);
if TotalB >= $7FFFFFFF then begin TotalB:= TotalMB; FreeB:= FreeMB; String:= PadL(ByteOrTB(TotalMB*oneMB, true),11) +' всего -'+ String end else String:= PadL(ByteOrTB(TotalB, true),11) +' всего| '+ String;
ListBox.Items[n]:= Copy(Path,1,2) + String + PadL(FloatToStr(round(FreeB/TotalB*100)),3)+ '% своб|'+ PadL(FileSystemName,5)+ '| '+ CutString(VolumeName,9); end; end;
End;

Procedure ObjectOnClick(Sender: TObject); Begin
Case TObject(Sender) of
ListBox: for n:= 0 to ListBox.Items.Count-1 do if ListBox.Selected[n] then WizardForm.DirEdit.Text:= Copy(ListBox.Items[n],1,1) +Copy(WizardForm.DirEdit.Text, 2, Length(WizardForm.DirEdit.Text))
StartMenuTreeView: if StartMenuTreeView.Directory <> '' then WizardForm.GroupEdit.Text:= StartMenuTreeView.Directory else WizardForm.GroupEdit.Text:= '{#SetupSetting("DefaultGroupName")}'
WizardForm.NoIconsCheck: begin WizardForm.GroupEdit.Enabled:= not(WizardForm.GroupEdit.Enabled); StartMenuTreeView.Enabled:= WizardForm.GroupEdit.Enabled; WizardForm.GroupBrowseButton.Enabled:= WizardForm.GroupEdit.Enabled end;
end; End;

Function NextButtonClick(CurPageID: Integer): Boolean; Begin
Result:= True
if (CurPageID = wpSelectDir) and (Pos(Uppercase(ExpandConstant('{win}')), Uppercase(ExpandConstant('{app}'))) > 0) then Result:= MessageBox(StrToInt(ExpandConstant('{wizardhwnd}')), ExpandConstant('{cm:SysDirSelect}'), 'Установка в системную папку', MB_YESNO or $30) = idYes;
End;

Procedure CurPageChanged(CurPageID: Integer);
Begin
if CurPageID = wpSelectDir then ListBoxRefresh
End;

Procedure InitializeWizard;
Begin
ListBox:= TListBox.Create(WizardForm)
ListBox.SetBounds(WizardForm.DirEdit.Left, WizardForm.DirEdit.Top + WizardForm.DirEdit.Height + 8, WizardForm.DirBrowseButton.Left + WizardForm.DirBrowseButton.Width - WizardForm.DirEdit.Left, WizardForm.DiskSpaceLabel.Top - (WizardForm.DirEdit.Top + WizardForm.DirEdit.Height + 12))
ListBox.Font.Size:= 9
ListBox.Font.Style:= []
ListBox.Font.Name:= 'Courier New';
ListBox.OnClick:= @ObjectOnClick;
ListBox.Parent:= WizardForm.SelectDirPage;
WizardForm.NoIconsCheck.SetBounds(WizardForm.DiskSpaceLabel.Left + 96, WizardForm.DiskSpaceLabel.Top + 1, WizardForm.NoIconsCheck.Width, WizardForm.NoIconsCheck.Height)
WizardForm.NoIconsCheck.OnClick:= @ObjectOnClick
WizardForm.NoIconsCheck.Parent:= WizardForm.SelectProgramGroupPage
WizardForm.NoIconsCheck.Show
StartMenuTreeView:= TStartMenuFolderTreeView.Create(WizardForm)
StartMenuTreeView.SetPaths(ExpandConstant('{userprograms}'), ExpandConstant('{commonprograms}'), ExpandConstant('{userstartup}'), ExpandConstant('{commonstartup}'));
StartMenuTreeView.SetBounds(ListBox.Left, ListBox.Top, ListBox.Width, ListBox.Height)
StartMenuTreeView.Parent:= WizardForm.SelectProgramGroupPage
StartMenuTreeView.Cursor:= crHand
StartMenuTreeView.OnChange:=@ObjectOnClick
End; + function enabledesc(ComponentsListHandle: HWND; DescLabelHandle: HWND; DescStrings: PChar): BOOL; external 'enabledesc@files:descctrl.dll stdcall';

function disabledesc(): BOOL; external 'disabledesc@files:descctrl.dll stdcall';

var
Info: TNewStaticText;
InfoCaption: TNewStaticText;
InfoPanel: TPanel;

procedure DeinitializeSetup();
begin
disabledesc();
end;

procedure InitializeWizard();
begin
WizardForm.TYPESCOMBO.Visible:= false;
WizardForm.ComponentsList.Height := WizardForm.ComponentsList.Height + WizardForm.ComponentsList.Top - WizardForm.TYPESCOMBO.Top;
WizardForm.ComponentsList.Top := WizardForm.TYPESCOMBO.Top;
WizardForm.ComponentsList.Width := ScaleX(200);
InfoPanel := TPanel.Create(WizardForm);
InfoPanel.Parent := WizardForm.SelectComponentsPage;
InfoPanel.Caption := '';
InfoPanel.Top := WizardForm.ComponentsList.Top;
InfoPanel.Left := ScaleX(216);
InfoPanel.Width := ScaleX(200);
InfoPanel.Height := WizardForm.ComponentsList.Height;
InfoPanel.BevelInner := bvRaised;
InfoPanel.BevelOuter := bvLowered;
InfoCaption := TNewStaticText.Create(WizardForm);
InfoCaption.Parent := WizardForm.SelectComponentsPage;
InfoCaption.Caption := 'ГиКц';
InfoCaption.Left := ScaleX(224);
InfoCaption.Top := InfoPanel.Top - ScaleY(5);
InfoCaption.Font.Color := clActiveCaption;
Info := TNewStaticText.Create(WizardForm);
Info.Parent := InfoPanel;
Info.AutoSize := False;
Info.Left := ScaleX(6);
Info.Width := ScaleX(188);
Info.Top := ScaleY(12);
Info.Height := WizardForm.ComponentsList.Height - ScaleY(18);
Info.Caption := 'ТЖ¶ЇДгµДКу±кЦёХлµЅЧйјюЦ®ЙПЈ¬±гїЙјыµЅЛьµДГиКцЎЈ';
Info.WordWrap := true;
enabledesc(WizardForm.ComponentsList.Handle,Info.Handle,
'іМРтОДјюГиКц;'+
'°пЦъОДјюГиКц;'+
'ЧФКцОДјюГиКц;'+
'УўОДГиКц;'+
'µВОДГиКц;'+
'ЦРОДГиКц;'+
'¶нОДГиКцІвКФ#3B#3B°ьє¬#3BУўОД·ЦєЕ;'+
'ІвКФГиКц;'+
'ІвКФ1ГиКц;'+
'ІвКФ2ГиКц;'+
'ІвКФ3ГиКц;'+
'ІвКФ4ГиКц;'+
'ІвКФ5ГиКц;'+
'ІвКФ6ГиКц;'
);
end; + function ShouldSkipPage(CurPage: Integer): Boolean;
begin
if Pos('/SP-', UpperCase(GetCmdTail)) > 0 then
case CurPage of
wpLicense, wpPassword, wpInfoBefore, wpUserInfo,
wpSelectDir, wpSelectProgramGroup, wpInfoAfter:
Result := True;
end;
end;
const
WM_LBUTTONDOWN = 513;
WM_LBUTTONUP = 514;

procedure InitializeWizard();
begin
if (Pos('/SP-', UpperCase(GetCmdTail)) > 0) then
begin
PostMessage(WizardForm.NextButton.Handle,WM_LBUTTONDOWN,0,0);
PostMessage(WizardForm.NextButton.Handle,WM_LBUTTONUP,0,0);
end;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
if (Pos('/SP-', UpperCase(GetCmdTail)) > 0) and
(CurPageID = wpSelectComponents) then
WizardForm.BackButton.Visible := False;
end; + procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
Res: Integer;
begin
case CurUninstallStep of
usPostUninstall:
begin
//Проверяем присутствие папки после удаления
If DirExists(ExpandConstant('{app}')+'')
then
//Создаем диалог с тремя кнопками
case MsgBox('Папка "'+ExpandConstant('{app}')+'" не пуста.'#13#13 +
'"Да" – полное удаление всех файлов в папке, включая саму папку.' #13#13 +
'"Нет" – открыть папку в проводнике, чтобы вручную удалить файлы.'#13#13 +
'"Отмена" – ничего не делать, удалить папку позже самостоятельно.', mbInformation, MB_YESNOCANCEL)
of IDYES:
begin
if not DelTree(ExpandConstant('{app}')+'', True, True, True)
then
MsgBox('Папка не удалена.' #13#13 'Папка или один из файлов в ней задействованы другим приложением.', mbError, MB_OK);
end
IDNO:
begin
if not ShellExec('open', ExpandConstant('{app}')+'', '', '', SW_SHOWMAXIMIZED, ewNoWait, Res)
then
MsgBox('Ошибка открытия.' #13#13 'Папка не найдена.', mbError, MB_OK);
end
IDCANCEL:
begin
end;
end;
end;
end;
end;

//Будьте очень осторожны в таких случаях! Не позволим пользователю установить программу в уже существующую папку:
function NextButtonClick(CurPage: Integer): Boolean;
var
s, s2:string;
begin
Result:=True;
If CurPage=wpSelectDir
then
begin
s2:=ExpandConstant('{app}')+'';
If DirExists(s2)
then
begin
s:='Установка в существующую папку в целях безопасности невозможна!';
MsgBox(s, mbError, mb_Ok);
Result:=False;
end;
end;
end;




© OSzone.net 2001-2012