PDA

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


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

Dinvin4ester
01-07-2014, 22:18
http://sendfile.su/995934 ребята,можно-ли сюда добавить музыку и сделать чтоб инсталлятор был на русском и на англ,ну как бы сделать переключение.
Спасибо.

Dodakaedr
02-07-2014, 01:03
можно-ли сюда добавить музыку и сделать чтоб инсталлятор был на русском и на англ,ну как бы сделать переключение. »
Вот держите Ваш скрипт (http://rghost.ru/private/56682383/0b3699bf6c5efb640c42d76f4ebfe159) вам осталось только перевести текст на английский в секции [CustomMessages] и дописать остальные строчки в процедуре "ChangeLang()" (я там уже пару строк написал для примера). Но с кнопками Далее, Назад, Отмена я вам не помогу. Обратитесь к специалистам по ботве, или может сами решите...

El Sanchez
02-07-2014, 09:53
нужно, что бы препроцессор нашел все файлы в заданной папке и забил их в директиву. »
Fanat1990, держите пример. Для отладки раскомментируйте строку с pragma error, увидите результирующую строку.
#define FileHandle
#define FindResult
#define Resources

#sub ProcessFoundFile
#define FileName FindGetFileName(FileHandle)
#define public Resources Resources + FileName + ":""Files\" + FileName + """|"
#endsub

#for {FileHandle = FindResult = FindFirst("Files\*.*", 0); FindResult; FindResult = FindNext(FileHandle)} ProcessFoundFile

#if FileHandle
#expr FileClose(FileHandle)
#expr Delete(Resources, Len(Resources), 1)
#endif

;#pragma error Resources

[Setup]
RawDataResource={#Resources}


Возможно ли сделать такой установщик без использования библиотеки IsDone »
Kashtan007, можно хоть ракеты в космос запускать.

Fanat1990
02-07-2014, 16:09
El Sanchez, спасибо, то что нужно. Скажите, а как правильно прописать несколько директорий? К примеру файлы находятся в папках Files1 и Files2

El Sanchez
03-07-2014, 09:02
а как правильно прописать несколько директорий? К примеру файлы находятся в папках Files1 и Files2 »
Fanat1990, пробуйте:

#define PathList "Files|Files2"
#define FileHandle
#define FindResult
#define Resources ""

#define ResourcesEntry(str *Result, str ResName, str ResPath) \
(Len(ResName) && Len(ResPath)) ? \
Result = Result + ResName + ":""" + ResPath + "\" + ResName + """|" : \
Result

#sub ParseList
#define public Mask \
(Local[0] = Pos("|", PathList)) ? \
Copy(PathList, 1, Local[0]-1) + "\*.*" : \
PathList + "\*.*"
#for {FileHandle = FindResult = FindFirst(Mask, 0); FindResult; FindResult = FindNext(FileHandle)} \
ResourcesEntry(Resources, FindGetFileName(FileHandle), ExtractFilePath(Mask))
#endsub

#for {Len(PathList); Len(PathList); (Pos("|", PathList) ? Delete(PathList, 1, Pos("|", PathList)) : Delete(PathList, 1, Len(PathList)))} ParseList

#if FileHandle
#expr FileClose(FileHandle)
#expr Delete(Resources, Len(Resources), 1)
#endif

;#pragma error Resources

[Setup]
RawDataResource={#Resources}

habib2302
03-07-2014, 14:58
Всем привет. Помогите мне решить проблему. Мне давали код на закрепление ярлыков в панеле задач и в меню пуск 2 в1. при выборе этих двух заданий (Tasks), то закрепляется только на панеле, а в меню нет. вот скрипт
https://yadi.sk/d/mVOJwGQZVqMQw

El Sanchez
03-07-2014, 16:47
Мне давали код на закрепление ярлыков в панеле задач и в меню пуск 2 в1 »
2 в 1 не есть хорошо, ибо для закрепления ярлыка в меню Пуск код другой, а не та каша из булевых параметров, что вы привели. Разделите по функциям и используйте их отдельно:

function PinToTaskbar(const szFilename: String; IsPin: Boolean): Boolean;
// szFilename : full path to executable file
// IsPin......: False - unpin from TaskBar, True - pin to TaskBar
var
hInst: THandle;
buf: array [0..255] of Char;
i, res: Integer;
strLnk, strVerb: String;
objShell, colVerbs: Variant;
begin
Result := False;
if (GetWindowsVersion < $06010000) or not FileExists(szFilename) then Exit; { below Windows 7 }

{ String resources }
if IsPin then
begin
if SHGetNewLinkInfo(szFilename, ExpandConstant('{tmp}'), buf[0], res, 0) then
begin
while buf[Length(strLnk)] <> #0 do Insert(buf[Length(strLnk)], strLnk, Length(strLnk)+1);
if FileExists(ExpandConstant('{userappdata}\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\') + ExtractFileName(strLnk)) then Exit;
end;
res := 5386; { Pin to Tas&kbar }
end else res := 5387; { Unpin from Tas&kbar }

{ Load string resource }
hInst := LoadLibraryEx(ExpandConstant('{sys}\shell32.dll'), 0, LOAD_LIBRARY_AS_DATAFILE);
if hInst <> 0 then
try
for i := 0 to LoadString(hInst, res, buf[0], 255)-1 do Insert(buf[i], strVerb, i+1);
try
objShell := CreateOleObject('Shell.Application');
colVerbs := objShell.Namespace(ExtractFileDir(szFilename)).ParseName(ExtractFileName(szFilename)).Verbs;
for i := 1 to colVerbs.Count do if CompareText(colVerbs.Item[i].Name, strVerb) = 0 then
begin
colVerbs.Item[i].DoIt;
Result := True;
Break;
end;
except
Exit;
end;
finally
FreeDLL(hInst);
end;
end;



function PinToStartMenu(const szFilename: String; IsPin: Boolean): Boolean;
// szFilename : full path to exe- or lnk-file
// IsPin......: False - unpin from StartMenu, True - pin to StartMenu
var
hInst: THandle;
buf: array [0..259] of Char;
i, res: Integer;
strLnk, strVerb: String;
objShell, colVerbs: Variant;
begin
Result := False;
if not FileExists(szFilename) then Exit;
if GetWindowsVersion > $06020000 then Exit; { Window 8 and above }

{ Windows 7 }
if (GetWindowsVersion >= $06010000) and boolean(SHGetNewLinkInfo(szFilename, ExpandConstant('{tmp}'), buf[0], res, 0)) then
begin
while buf[Length(strLnk)] <> #0 do Insert(buf[Length(strLnk)], strLnk, Length(strLnk)+1);
if FileExists(ExpandConstant('{userappdata}\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu\') + ExtractFileName(strLnk)) then Exit;
end;

{ String resources }
if IsPin then
res := 5381 { Pin to Start Men&u }
else
res := 5382; { Unpin from Start Men&u }

{ Load string resource }
hInst := LoadLibraryEx(ExpandConstant('{sys}\shell32.dll'), 0, LOAD_LIBRARY_AS_DATAFILE);
if hInst <> 0 then
try
for i := 0 to LoadString(hInst, res, buf[0], 255)-1 do Insert(buf[i], strVerb, i+1);
try
objShell := CreateOleObject('Shell.Application');

{ below Windows 7 }
if GetWindowsVersion < $06010000 then
begin
objShell.Namespace(ExtractFileDir(szFilename)).ParseName(ExtractFileName(szFilename)).InvokeVerb(str Verb);
Result := True;
end;

{ Windows 7 }
if GetWindowsVersion >= $06010000 then
begin
colVerbs := objShell.Namespace(ExtractFileDir(szFilename)).ParseName(ExtractFileName(szFilename)).Verbs;
for i := 1 to colVerbs.Count do if CompareText(colVerbs.Item[i].Name, strVerb) = 0 then
begin
colVerbs.Item[i].DoIt;
Result := True;
Break;
end;
end;
except
Exit;
end;
finally
FreeDLL(hInst);
end;
end;

habib2302
03-07-2014, 17:38
El Sanchez, Выдает ошибку
http://i.imgur.com/SBUtTMH.png (http://i.imgur.com/uCeNef3.png)

YURSHAT
03-07-2014, 18:32
habib2302, компилятор говорит, что вы передаете неправильное количество параметров. В функции у вас два параметра, а вы передаете 3. Уберите ненужный булевый параметр.

if IsTaskSelected('icons\taskbaricon') then
PinToTaskbar(ExpandConstant('{app}\{#MyAppExeName}'), True);
if IsTaskSelected('icons\startmenuicon') then
PinToStartMenu(ExpandConstant('{app}\{#MyAppExeName}'), True);

habib2302
03-07-2014, 18:42
YURSHAT, как я понимаю должно быть так?

Procedure CurPageChanged(CurPageID: Integer);
Begin
Case CurPageID of
wpFinished:
begin
if IsTaskSelected('icons\taskbaricon') then
PinToTaskbar(ExpandConstant('{app}\{#MyAppExeName}'), True);
if IsTaskSelected('icons\startmenuicon') then
PinToStartMenu(ExpandConstant('{app}\{#MyAppExeName}'), True);
end;
end;
end;

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
instPath: string;
begin
case CurUninstallStep of
usUninstall:
begin
PinToTaskbar(ExpandConstant('{app}\{#MyAppExeName}'), False);
PinToStartMenu(ExpandConstant('{app}\{#MyAppExeName}'), False);
end;
end;
end;

Dodakaedr
03-07-2014, 18:50
Как себя будет вести этот код если ярлык перед установкой уже будет существовать?
function PinToStartMenu(const szFilename: String; IsPin: Boolean): Boolean;
// szFilename : full path to exe- or lnk-file
// IsPin......: False - unpin from StartMenu, True - pin to StartMenu
var
hInst: THandle;
buf: array [0..259] of Char;
i, res: Integer;
strLnk, strVerb: String;
objShell, colVerbs: Variant;
begin
Result := False;
if not FileExists(szFilename) then Exit;
if GetWindowsVersion > $06020000 then Exit; { Window 8 and above }

{ Windows 7 }
if (GetWindowsVersion >= $06010000) and boolean(SHGetNewLinkInfo(szFilename, ExpandConstant('{tmp}'), buf[0], res, 0)) then
begin
while buf[Length(strLnk)] <> #0 do Insert(buf[Length(strLnk)], strLnk, Length(strLnk)+1);
if FileExists(ExpandConstant('{userappdata}\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu\') + ExtractFileName(strLnk)) then Exit;
end;

{ String resources }
if IsPin then
res := 5381 { Pin to Start Men&u }
else
res := 5382; { Unpin from Start Men&u }

{ Load string resource }
hInst := LoadLibraryEx(ExpandConstant('{sys}\shell32.dll'), 0, LOAD_LIBRARY_AS_DATAFILE);
if hInst <> 0 then
try
for i := 0 to LoadString(hInst, res, buf[0], 255)-1 do Insert(buf[i], strVerb, i+1);
try
objShell := CreateOleObject('Shell.Application');

{ below Windows 7 }
if GetWindowsVersion < $06010000 then
begin
objShell.Namespace(ExtractFileDir(szFilename)).ParseName(ExtractFileName(szFilename)).InvokeVerb(str Verb);
Result := True;
end;

{ Windows 7 }
if GetWindowsVersion >= $06010000 then
begin
colVerbs := objShell.Namespace(ExtractFileDir(szFilename)).ParseName(ExtractFileName(szFilename)).Verbs;
for i := 1 to colVerbs.Count do if CompareText(colVerbs.Item[i].Name, strVerb) = 0 then
begin
colVerbs.Item[i].DoIt;
Result := True;
Break;
end;
end;
except
Exit;
end;
finally
FreeDLL(hInst);
end;
end;

habib2302
03-07-2014, 18:54
Dodakaedr, а что?если по поводу создания 2 копии, то этого не происходит

Dodakaedr
03-07-2014, 18:57
а что?если по поводу создания 2 копии, то этого не происходит »
Не знаю. Вот и справшиваю? Не будет ли там какой то ошибки???

habib2302
03-07-2014, 19:00
Не будет ли там какой то ошибки??? »
Проверил. Нет, не будет!

Dinvin4ester
03-07-2014, 19:31
Dodakaedr,
Ага,спасибо,там сделаю..,апд заметил что в русс,что в енг все черным .. я имею ввиду выбор - http://i61.fastpic.ru/big/2014/0703/8f/d2d1f0a5099f8b58158a9ede2fe6008f.png ?
Как побороть ?

El Sanchez
03-07-2014, 21:28
Как себя будет вести этот код если ярлык перед установкой уже будет существовать? »
Dodakaedr, для систем ниже Windows 7 при повторном запуске функции при наличии закрепленного ярлыка ничего не произойдет, даже проверку на наличие не надо делать. Для Windows 7 нужно, чтобы клоны не плодились. В скрипте эта проверка есть, трудно не заметить. Копипаста заменила стремление к получению ответа на вопрос: как это работает?

Dodakaedr
03-07-2014, 21:38
при повторном запуске функции при наличии закрепленного ярлыка ничего не произойдет, »

Даже если устанавливать в разные папки?

habib2302
03-07-2014, 21:59
Dodakaedr, да. тоже проверил

Dodakaedr
03-07-2014, 22:00
habib2302, Отлично!

Dodakaedr
03-07-2014, 22:54
Как побороть ? »
Просто. Замените эту часть кода у себя: //Выберите дополнительные задачи 4 страница
TaskLabel:= TLabel.Create(WizardForm);
with TaskLabel do begin
Left:= 30;
Top:= 270;
Width:= 540;
Height:= 74;
AutoSize:= false;
Transparent:= true;
WordWrap:= true;
//ParentFont := True;
Parent:= WizardForm;
Caption:=ExpandConstant('{cm:rusTask}');
end;


#ifdef TaskCheckBox
#if TaskCheckBox == "4"

hSoftBtn1:=BtnCreate(WizardForm.Handle,60,305,20,20,ExpandConstant('{tmp}\Button3.png'),8,True);
BtnSetEvent(hSoftBtn1,BtnClickEventID,WrapBtnCallback(@Soft1Click,1));
BtnSetChecked(hSoftBtn1,True);
hSoftBtn2:=BtnCreate(WizardForm.Handle,60,335,20,20,ExpandConstant('{tmp}\Button3.png'),8,True);
BtnSetEvent(hSoftBtn2,BtnClickEventID,WrapBtnCallback(@Soft2Click,1));
BtnSetChecked(hSoftBtn2,True);
hSoftBtn3:=BtnCreate(WizardForm.Handle,300,305,20,20,ExpandConstant('{tmp}\Button3.png'),8,True);
BtnSetEvent(hSoftBtn3,BtnClickEventID,WrapBtnCallback(@Soft3Click,1));
BtnSetChecked(hSoftBtn3,True);
hSoftBtn4:=BtnCreate(WizardForm.Handle,300,335,20,20,ExpandConstant('{tmp}\Button3.png'),8,True);
BtnSetEvent(hSoftBtn4,BtnClickEventID,WrapBtnCallback(@Soft4Click,1));
BtnSetChecked(hSoftBtn4,True);

Soft1Label:= TLabel.Create(WizardForm);
with Soft1Label do begin
Left:= 82;
Top:= 307;
Width:= 200;
Height:= 20;
AutoSize:= false;
Transparent:= true;
WordWrap:= true;
ParentFont := True;
Parent:= WizardForm;
OnClick:= @Soft1LabelClick;
Caption:=ExpandConstant('{cm:rusSoft1}');
end;

Soft2Label:= TLabel.Create(WizardForm);
with Soft2Label do begin
Left:= 82;
Top:= 337;
Width:= 200;
Height:= 20;
AutoSize:= false;
Transparent:= true;
WordWrap:= true;
ParentFont := True;
Parent:= WizardForm;
OnClick:= @Soft2LabelClick;
Caption:=ExpandConstant('{cm:rusSoft2}');
end;

Soft3Label:= TLabel.Create(WizardForm);
with Soft3Label do begin
Left:= 321;
Top:= 306;
Width:= 290;
Height:= 20;
AutoSize:= false;
Transparent:= true;
WordWrap:= true;
ParentFont := True;
Parent:= WizardForm;
OnClick:= @Soft3LabelClick;
Caption:=ExpandConstant('{cm:rusSoft3}');
end;

Soft4Label:= TLabel.Create(WizardForm);
with Soft4Label do begin
Left:= 321;
Top:= 336;
Width:= 300;
Height:= 20;
AutoSize:= false;
Transparent:= true;
WordWrap:= true;
ParentFont := True;
Parent:= WizardForm;
OnClick:= @Soft4LabelClick;
Caption:=ExpandConstant('{cm:rusSoft4}');
end;
#else
#if TaskCheckBox == "3"

hSoftBtn1:=BtnCreate(WizardForm.Handle,70,305,20,20,ExpandConstant('{tmp}\Button3.png'),8,True);
BtnSetEvent(hSoftBtn1,BtnClickEventID,WrapBtnCallback(@Soft1Click,1));
BtnSetChecked(hSoftBtn1,True);
hSoftBtn2:=BtnCreate(WizardForm.Handle,70,335,20,20,ExpandConstant('{tmp}\Button3.png'),8,True);
BtnSetEvent(hSoftBtn2,BtnClickEventID,WrapBtnCallback(@Soft2Click,1));
BtnSetChecked(hSoftBtn2,True);
hSoftBtn3:=BtnCreate(WizardForm.Handle,330,315,20,20,ExpandConstant('{tmp}\Button3.png'),8,True);
BtnSetEvent(hSoftBtn3,BtnClickEventID,WrapBtnCallback(@Soft3Click,1));
BtnSetChecked(hSoftBtn3,True);

Soft1Label:= TLabel.Create(WizardForm);
with Soft1Label do begin
Left:= 92;
Top:= 307;
Width:= 200;
Height:= 20;
AutoSize:= false;
Transparent:= true;
WordWrap:= true;
ParentFont := True;
Parent:= WizardForm;
OnClick:= @Soft1LabelClick;
Caption:=ExpandConstant('{cm:rusSoft1}');
end;

Soft2Label:= TLabel.Create(WizardForm);
with Soft2Label do begin
Left:= 92;
Top:= 337;
Width:= 200;
Height:= 20;
AutoSize:= false;
Transparent:= true;
WordWrap:= true;
ParentFont := True;
Parent:= WizardForm;
OnClick:= @Soft2LabelClick;
Caption:=ExpandConstant('{cm:rusSoft2}');
end;

Soft3Label:= TLabel.Create(WizardForm);
with Soft3Label do begin
Left:= 351;
Top:= 317;
Width:= 290;
Height:= 30;
AutoSize:= false;
Transparent:= true;
WordWrap:= true;
ParentFont := True;
Parent:= WizardForm;
OnClick:= @Soft3LabelClick;
Caption:=ExpandConstant('{cm:rusSoft3}');
end;

#else
#if TaskCheckBox == "2"

hSoftBtn1:=BtnCreate(WizardForm.Handle,70,320,20,20,ExpandConstant('{tmp}\Button3.png'),8,True);
BtnSetEvent(hSoftBtn1,BtnClickEventID,WrapBtnCallback(@Soft1Click,1));
BtnSetChecked(hSoftBtn1,True);
hSoftBtn2:=BtnCreate(WizardForm.Handle,280,320,20,20,ExpandConstant('{tmp}\Button3.png'),8,True);
BtnSetEvent(hSoftBtn2,BtnClickEventID,WrapBtnCallback(@Soft2Click,1));
BtnSetChecked(hSoftBtn2,True);

Soft1Label:= TLabel.Create(WizardForm);
with Soft1Label do begin
Left:= 90;
Top:= 322;
Width:= 200;
Height:= 20;
AutoSize:= false;
Transparent:= true;
WordWrap:= true;
ParentFont := True;
Parent:= WizardForm;
OnClick:= @Soft1LabelClick;
Caption:=ExpandConstant('{cm:rusSoft1}');
end;

Soft2Label:= TLabel.Create(WizardForm);
with Soft2Label do begin
Left:= 305;
Top:= 322;
Width:= 200;
Height:= 20;
AutoSize:= false;
Transparent:= true;
WordWrap:= true;
ParentFont := True;
Parent:= WizardForm;
OnClick:= @Soft2LabelClick;
Caption:=ExpandConstant('{cm:rusSoft2}');
end;
#else
#if TaskCheckBox == "1"

hSoftBtn1:=BtnCreate(WizardForm.Handle,60,305,20,20,ExpandConstant('{tmp}\Button3.png'),8,True);
BtnSetEvent(hSoftBtn1,BtnClickEventID,WrapBtnCallback(@Soft1Click,1));
BtnSetChecked(hSoftBtn1,True);
hSoftBtn2:=BtnCreate(WizardForm.Handle,60,335,20,20,ExpandConstant('{tmp}\Button3.png'),8,True);
BtnSetEvent(hSoftBtn2,BtnClickEventID,WrapBtnCallback(@Soft2Click,1));
BtnSetChecked(hSoftBtn2,True);
hSoftBtn3:=BtnCreate(WizardForm.Handle,300,305,20,20,ExpandConstant('{tmp}\Button3.png'),8,True);
BtnSetEvent(hSoftBtn3,BtnClickEventID,WrapBtnCallback(@Soft3Click,1));
BtnSetChecked(hSoftBtn3,True);
hSoftBtn5:=BtnCreate(WizardForm.Handle,300,335,20,20,ExpandConstant('{tmp}\Button3.png'),8,True);
BtnSetEvent(hSoftBtn5,BtnClickEventID,WrapBtnCallback(@Soft5Click,1));
BtnSetChecked(hSoftBtn5,True);

Soft1Label:= TLabel.Create(WizardForm);
with Soft1Label do begin
Left:= 82;
Top:= 307;
Width:= 200;
Height:= 20;
AutoSize:= false;
Transparent:= true;
WordWrap:= true;
ParentFont := True;
Parent:= WizardForm;
OnClick:= @Soft1LabelClick;
Caption:=ExpandConstant('{cm:rusSoft1}');
end;

Soft2Label:= TLabel.Create(WizardForm);
with Soft2Label do begin
Left:= 82;
Top:= 337;
Width:= 200;
Height:= 20;
AutoSize:= false;
Transparent:= true;
WordWrap:= true;
ParentFont := True;
Parent:= WizardForm;
OnClick:= @Soft2LabelClick;
Caption:=ExpandConstant('{cm:rusSoft2}');
end;

Soft3Label:= TLabel.Create(WizardForm);
with Soft3Label do begin
Left:= 321;
Top:= 306;
Width:= 290;
Height:= 20;
AutoSize:= false;
Transparent:= true;
WordWrap:= true;
ParentFont := True;
Parent:= WizardForm;
OnClick:= @Soft3LabelClick;
Caption:=ExpandConstant('{cm:rusSoft3}');
end;

Soft5Label:= TLabel.Create(WizardForm);
with Soft5Label do begin
Left:= 321;
Top:= 336;
Width:= 300;
Height:= 20;
AutoSize:= false;
Transparent:= true;
WordWrap:= true;
ParentFont := True;
Parent:= WizardForm;
OnClick:= @Soft5LabelClick;
Caption:=ExpandConstant('{cm:rusSoft5}');
end;




© OSzone.net 2001-2012