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

habib2302
27-06-2014, 00:55
Dodakaedr, как в этом же скрите сделать так, чтобы ярлыки создавались в зависимости от битности файлов и системы

Dodakaedr
27-06-2014, 01:02
как в этом же скрите сделать так, чтобы ярлыки создавались в зависимости от битности файлов и системы »
используйте стандартную функцию "IsWin64" для 64 битных и "not IsWin64" для 32 битных

habib2302
27-06-2014, 01:08
Dodakaedr, я так и сделал

#define MyAppExeNamex86 "CCleaner.exe"
#define MyAppExeNamex64 "CCleaner64.exe"

[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application
CreateUninstallRegKey=false

[Files]
Source: CCleaner.exe; DestDir: {app}\bin;
Source: CCleaner64.exe; DestDir: {app}\bin;

[Tasks]
Name: PinToTaskBar; Description: {cm:cTaskBarTxt}; MinVersion: 0,6.0;
Name: PinToStartMenu; Description: {cm:cStartMenuTxt}; MinVersion: 0,6.0;

[Languages]
Name: "ru"; MessagesFile: "compiler:Languages\Russian.isl"
Name: "en"; MessagesFile: "compiler:Languages\English.isl"

[CustomMessages]
ru.cTaskBarTxt=Закрепить на панели задач
ru.cStartMenuTxt=Закрепить в меню "Пуск"
en.cTaskBarTxt=Pin to Taskbar
en.cStartMenuTxt=Pin to Start Menu

[ Code]
const
LOAD_LIBRARY_AS_DATAFILE = $2;

#define A = (Defined UNICODE) ? "W" : "A"

function LoadLibraryEx(lpFileName: String; hFile: THandle; dwFlags: DWORD): THandle; external 'LoadLibraryEx{#A}@kernel32.dll stdcall';
function LoadString(hInstance: THandle; uID: SmallInt; var lpBuffer: Char; nBufferMax: Integer): Integer; external 'LoadString{#A}@user32.dll stdcall';
function SHGetNewLinkInfo(pszLinkTo, pszDir: String; var pszName: Char; var pfMustCopy: Longint; uFlags: UINT): BOOL; external 'SHGetNewLinkInfo{#A}@shell32.dll stdcall';

/////////////////////////////////////////////////////////////////////////
function PinToTaskbar(const szFilename: String; TaskBar, IsPin: Boolean): Boolean;
//szFilename: full path to executable file
//TaskBar: False - pin to StartMenu, True - pin to TaskBar
//IsPin: False - unpin from TaskBar/StartMenu, True - pin to TaskBar/StartMenu
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;
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;
if TaskBar then res := 5386 else res := 5381;
end else if TaskBar then res := 5387 else res := 5382;
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;

procedure CurPageChanged(CurPageID: integer);
begin
case CurPageID of
wpFinished:
begin
if IsTaskSelected('PinToTaskBar') and not iswin64 then
PinToTaskbar(ExpandConstant('{#MyAppExeNamex86}'), True, True);
if IsTaskSelected('PinToStartMenu') and not iswin64 then
PinToTaskbar(ExpandConstant('{#MyAppExeNamex86}'), False, True);
if IsTaskSelected('PinToTaskBar') and iswin64 then
PinToTaskbar(ExpandConstant('{#MyAppExeNamex64}'), True, True);
if IsTaskSelected('PinToStartMenu') and iswin64 then
PinToTaskbar(ExpandConstant('{#MyAppExeNamex64}'), False, True);
end;
end;
end;

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
instPath: string;
begin
case CurUninstallStep of
usUninstall: begin
if not iswin64 then
PinToTaskbar(ExpandConstant('{#MyAppExeNamex86}'), True, False);
if not iswin64 then
PinToTaskbar(ExpandConstant('{#MyAppExeNamex86}'), False, False);
if iswin64 then
PinToTaskbar(ExpandConstant('{#MyAppExeNamex64}'), True, False);
if iswin64 then
PinToTaskbar(ExpandConstant('{#MyAppExeNamex64}'), False, False);
end;
end;
end;

но оно не работает

Dodakaedr
27-06-2014, 01:23
но оно не работает »
А так? #define MyAppExeName "{app}\bin\CCleaner.exe"

[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application
CreateUninstallRegKey=false

[Files]
Source: CCleaner.exe; DestDir: "{app}\bin"; Check: not IsWin64;
Source: CCleaner64.exe; DestDir: "{app}\bin"; DestName: "CCleaner.exe" Check: IsWin64;

[Tasks]
Name: PinToTaskBar; Description: {cm:cTaskBarTxt}; MinVersion: 0,6.0;
Name: PinToStartMenu; Description: {cm:cStartMenuTxt}; MinVersion: 0,6.0;

[Languages]
Name: "ru"; MessagesFile: "compiler:Languages\Russian.isl"
Name: "en"; MessagesFile: "compiler:Languages\English.isl"

[CustomMessages]
ru.cTaskBarTxt=Закрепить на панели задач
ru.cStartMenuTxt=Закрепить в меню "Пуск"
en.cTaskBarTxt=Pin to Taskbar
en.cStartMenuTxt=Pin to Start Menu

[ Code]
const
LOAD_LIBRARY_AS_DATAFILE = $2;

#define A = (Defined UNICODE) ? "W" : "A"

function LoadLibraryEx(lpFileName: String; hFile: THandle; dwFlags: DWORD): THandle; external 'LoadLibraryEx{#A}@kernel32.dll stdcall';
function LoadString(hInstance: THandle; uID: SmallInt; var lpBuffer: Char; nBufferMax: Integer): Integer; external 'LoadString{#A}@user32.dll stdcall';
function SHGetNewLinkInfo(pszLinkTo, pszDir: String; var pszName: Char; var pfMustCopy: Longint; uFlags: UINT): BOOL; external 'SHGetNewLinkInfo{#A}@shell32.dll stdcall';

/////////////////////////////////////////////////////////////////////////
function PinToTaskbar(const szFilename: String; TaskBar, IsPin: Boolean): Boolean;
//szFilename: full path to executable file
//TaskBar: False - pin to StartMenu, True - pin to TaskBar
//IsPin: False - unpin from TaskBar/StartMenu, True - pin to TaskBar/StartMenu
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;
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;
if TaskBar then res := 5386 else res := 5381;
end else if TaskBar then res := 5387 else res := 5382;
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;

procedure CurPageChanged(CurPageID: integer);
begin
case CurPageID of
wpFinished:
begin
if IsTaskSelected('PinToTaskBar') then
PinToTaskbar(ExpandConstant('{#MyAppExeName}'), True, True);
if IsTaskSelected('PinToStartMenu') then
PinToTaskbar(ExpandConstant('{#MyAppExeName}'), False, True);
if IsTaskSelected('PinToTaskBar') then
PinToTaskbar(ExpandConstant('{#MyAppExeName}'), True, True);
if IsTaskSelected('PinToStartMenu') then
PinToTaskbar(ExpandConstant('{#MyAppExeName}'), False, True);
end;
end;
end;

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

habib2302
27-06-2014, 12:26
Dodakaedr, не то

audiofeel
27-06-2014, 19:12
как организовать вот так же как на скрине (при помощи b2p), пробывал при помощи CreateBitmapRgn, края получаются какие то рванные, пример был, "потерял"

Dodakaedr
27-06-2014, 21:35
habib2302, Что не так?

habib2302
27-06-2014, 22:45
Dodakaedr, все не так

habib2302
28-06-2014, 18:43
Всем привет. Мне давали код для изменения пути установки в зависимости от компонента и не работает команда /DIR
procedure CurPageChanged(CurPageID: Integer);
begin
case CurPageID of
wpSelectProgramGroup:
begin
if IsComponentSelected('AIDA642') then
begin
WizardForm.DirEdit.Text := AddBackslash(ExpandConstant('{#SetupSetting("DefaultDirName")}')) + '{#AIDA642}';
WizardForm.GroupEdit.Text := AddBackslash(ExpandConstant('{#SetupSetting("DefaultGroupName")}')) + '{#AIDA642}';
end else begin
WizardForm.DirEdit.Text := ExpandConstant('{#SetupSetting("DefaultDirName")}');
WizardForm.GroupEdit.Text := ExpandConstant('{#SetupSetting("DefaultGroupName")}');
end;
end;
end;
end;

Dodakaedr
28-06-2014, 20:28
Всем привет. Я хочу сократить команды например для тихой установки. . . т.е убрать »
Ну что-то типа этого:
[Setup]
AppName=My Program
AppVerName=My Program v.1.2
DefaultDirName={pf}\My Program

[Files]
Source: "compiler:Languages\Russian.isl"; DestDir: "{app}"; DestName: "aida64.isl"; Check: aida64check;
Source: "compiler:Default.isl"; DestDir: "{app}"; DestName: "aida32.isl"; Check: aida32check;

[Components]
Name: rut; Description: rupol;

[ Code]
var
ComponentsList: TNewCheckListBox;

function CheckParam(s: string): boolean;
var
i: integer;
begin
for i := 0 to ParamCount do begin
Result := ParamStr(i) = s;
if Result then Break;
end;
end;

function IsComponent(CompIndex: Integer): Boolean;
var
i: Integer;
begin
Result := False;
for i := 0 to ComponentsList.ItemCount - 1 do
begin
if CompIndex <= (ComponentsList.ItemCount - 1) then
Result := ComponentsList.Checked[CompIndex];
end;
end;

function aida64check: Boolean;
begin
if CheckParam('/AIDA64') or CheckParam('/AIDA32') then
Result := CheckParam('/AIDA64')
else
Result := IsComponent(1);
end;

function aida32check: Boolean;
begin
if CheckParam('/AIDA64') or CheckParam('/AIDA32') then
Result := CheckParam('/AIDA32')
else
Result := IsComponent(2);
end;

procedure RedesignWizardForm;
begin
ComponentsList := TNewCheckListBox.Create(WizardForm);
with ComponentsList do
begin
Parent := WizardForm.SelectComponentsPage;
SetBounds(ScaleX(0), ScaleY(61), ScaleX(417), ScaleY(169));
AddCheckBox('Версия', '', 0, True, False, False, True, nil);
AddRadioButton('AIDA64', '1.5 GB', 1, true, True, nil);
AddRadioButton('AIDA32', '0.8 GB', 1, false, True, nil);
end;
end;

procedure InitializeWizard();
begin
RedesignWizardForm;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
case CurPageID of
wpSelectcomponents:
begin
WizardForm.ComponentsList.Hide;
WizardForm.TypesCombo.Hide;
end;
end;
end;


При использовании стандартного компонент листа:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program

[Components]
Name: "aida64"; Description: "AIDA64"; Flags: exclusive
Name: "aida32"; Description: "AIDA32"; Flags: exclusive

[Files]
Source: "compiler:Languages\Russian.isl"; DestDir: "{app}"; DestName: "aida64.isl"; Check: aida64check;
Source: "compiler:Default.isl"; DestDir: "{app}"; DestName: "aida32.isl"; Check: aida32check;

[ Code]
function CheckParam(s: string): boolean;
var
i: integer;
begin
for i := 0 to ParamCount do begin
Result := ParamStr(i) = s;
if Result then Break;
end;
end;

function aida64check: Boolean;
begin
if CheckParam('/AIDA64') or CheckParam('/AIDA32') then
Result := CheckParam('/AIDA64')
else
Result := WizardForm.ComponentsList.Checked[0];
end;

function aida32check: Boolean;
begin
if CheckParam('/AIDA64') or CheckParam('/AIDA32') then
Result := CheckParam('/AIDA32')
else
Result := WizardForm.ComponentsList.Checked[1];
end;

valyok666
28-06-2014, 20:44
как организовать вот так же как на скрине (при помощи b2p), пробывал при помощи CreateBitmapRgn, края получаются какие то рванные, пример был, "потерял" »
форму с нуля надо делать,остальное дело рук Фотошопа =)

habib2302
28-06-2014, 23:04
Куда все подевались? Кто нибудь ответит на мой вопрос? http://forum.oszone.net/post-2369579-989.html

Dodakaedr
28-06-2014, 23:18
Кто нибудь ответит на мой вопрос? »
Без скрипта, или хотя бы аналогичного примера - врядли!

audiofeel
28-06-2014, 23:25
форму с нуля надо делать,остальное дело рук Фотошопа »
да не, графика та есть, как сделать тень?? и бмп маска есть и сама форма png, но в оригинале она получается норм, а я взял пример из CreateBitmapRgn и края какие то рваные получаются, с какой то черной обводкой

;Created by South.Tver 02.2011
;пример работы с с прозрачностью изображения
#include "Modules\botva2.iss"

[Setup]
AppName=Transparent Image
AppVerName=Transparent Image
DefaultDirName={pf}\Transparent Image
SolidCompression=yes
Compression=lzma2/ultra64

[Files]
Source: Files\*; DestDir: "{tmp}"; Flags: dontcopy sortfilesbyextension

[-Code]
var
img: LongInt;

function LoadImage(hInst: THandle; ImageName: PChar; ImageType: UINT; X, Y: Integer; Flags: UINT): THandle; external 'LoadImageA@user32.dll stdcall';
function GetDC(hWnd: HWND): Longword; external 'GetDC@user32.dll stdcall';
function SetWindowRgn(hWnd: HWND; hRgn: LongWord; bRedraw: BOOL): Integer; external 'SetWindowRgn@user32.dll stdcall';
function ReleaseDC(hWnd: HWND; hDC: LongWord): Integer; external 'ReleaseDC@user32.dll stdcall';
function DeleteObject(p1: LongWord): BOOL; external 'DeleteObject@gdi32.dll stdcall';

function InitializeSetup:boolean;
begin
if not FileExists(ExpandConstant('{tmp}\b2p.dll')) then ExtractTemporaryFile('b2p.dll');
if not FileExists(ExpandConstant('{tmp}\botva2.dll')) then ExtractTemporaryFile('botva2.dll');
if not FileExists(ExpandConstant('{tmp}\CallbackCtrl.dll')) then ExtractTemporaryFile('CallbackCtrl.dll');
Result:=True;
end;

procedure SetRgn(h:HWND;FileName:string;Width,Height:integer);
var
dc:LongWord;
FRgn:LongWord;
bmp:HBITMAP;
begin
BMP:=LoadImage(0,PAnsiChar(ExpandConstant('{tmp}')+'\'+FileName),0,Width,Height,$10);
dc:=GetDC(h);
FRgn:=CreateBitmapRgn(dc,bmp,$FFFFFF,0,0);
SetWindowRgn(h,FRgn,True);
ReleaseDC(h,dc);
DeleteObject(BMP);
end;

procedure InitializeWizard;
var
i:integer;
begin
with WizardForm do begin
Bevel.Hide;
InnerNotebook.Hide;
OuterNotebook.Hide;
ClientWidth:=500;
ClientHeight:=550;
Position:=poScreenCenter;
NextButton.Width:=0;
CancelButton.Top:=515;
end;

ExtractTemporaryFile('mask.bmp');
SetRgn(WizardForm.Handle,'mask.bmp', 500, 550);

end;

procedure DeinitializeSetup;
begin
gdipShutdown;
end;

Dodakaedr
28-06-2014, 23:44
audiofeel, Попробуйте это: [ Code]
function GetWindowLong(Wnd: HWnd; Index: Integer): Longint; external 'GetWindowLongA@user32.dll stdcall';
function SetClassLong(hWnd: HWND; Index, NewLong: Longint): Longint; external 'SetClassLongA@user32 stdcall';

procedure InitializeWizard;
begin
WizardForm.BorderStyle:= bsNone; //Скрываем границы инсталлятора
SetClassLong(WizardForm.Handle, (-26), GetWindowLong(WizardForm.Handle, (-26)) or $00020000); //Чтобы отрисовалась тень от окна инсталлятора
end;

habib2302
28-06-2014, 23:53
Dodakaedr, вот скрипт

; Скрипт создан через Мастер Inno Setup Script.
; ИСПОЛЬЗУЙТЕ ДОКУМЕНТАЦИЮ ДЛЯ ПОДРОБНОСТЕЙ ИСПОЛЬЗОВАНИЯ INNO SETUP!

#define MyAppName "Display Driver Uninstaller"
#define MyAppVersion "12.9.3.0"
#define MyAppURL "http://www.wagnardmobile.com/DDU/"
#define MyAppExeName "Display Driver Uninstaller.exe"
#include "WinTB.iss"
#include "botva2.iss"

[Setup]
; Примечание: Значение AppId идентифицирует это приложение.
; Не используйте одно и тоже значение в разных установках.
; (Для генерации значения GUID, нажмите Инструменты | Генерация GUID.)
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
AllowNoIcons=true
OutputBaseFilename={#MyAppName} {#MyAppVersion} RePack (& Portable) by Xabib
SetupIconFile=ico.ico
Compression=lzma/Ultra64
SolidCompression=true
InternalCompressLevel=Ultra64
DiskSpanning=false
DiskSliceSize=736000000
ShowLanguageDialog=yes
SlicesPerDisk=4
UninstallDisplayIcon={app}\ico.ico
RawDataResource=Botva:botva2.dll|b2p:b2p.dll|Logo:logo.png|bPic:bPic.png|LiPic:LiPic.png|aPic:aPic.p ng
AppModifyPath={app}
VersionInfoProductName={#MyAppName}
DirExistsWarning=no
AppendDefaultDirName=false
AppendDefaultGroupName=false
DisableReadyPage=true
AppID={#MyAppName}
VersionInfoDescription={#MyAppName} RePack by Xabib
AppCopyright=Xabib © 2014
VersionInfoVersion={#MyAppVersion}
VersionInfoProductVersion={#MyAppVersion}
VersionInfoCopyright=Xabib © 2014
DisableFinishedPage=false
UninstallDisplayName={#MyAppName}
ComponentsListTVStyle=true
ShowComponentSizes=false
Uninstallable=not IsComponentSelected('DDU\P')
DisableProgramGroupPage=yes
CreateUninstallRegKey=not IsComponentSelected('DDU\P')

[Languages]
Name: "Russian"; MessagesFile: "Russian.isl"

[Types]
Name: full; Description: Полная установка; Flags: iscustom

[Tasks]
Name: icons; Description: {cm:AdditionalIcons}; Components: DDU\I;
Name: icons\desktop; Description: {cm:CreateDesktopIcon}; Components: DDU\I;
Name: icons\group; Description: {cm:CreateGroupIcon}; Components: DDU\I;
Name: icons\quicklaunchicon; Description: {cm:CreateQuickLaunchIcon}; OnlyBelowVersion: 0,6.1; Components: DDU\I;
Name: icons\taskbaricon; Description: {cm:CreateQuickLaunchIcon}; MinVersion: 0.0,6.1.7600; Components: DDU\I; Flags: unchecked;

[Components]
Name: DDU; Description: {#MyAppName}; Flags: fixed disablenouninstallwarning; Types: full;
Name: DDU\I; Description: Установить {#MyAppName}; Flags: exclusive disablenouninstallwarning
Name: DDU\P; Description: Распаковать {#MyAppName}; Flags: exclusive disablenouninstallwarning

[Files]
;Файлы распаковываемые в папку с игрой. Необходимы для деинсталлятора;
Source: WinTB.dll; Flags: dontcopy;
Source: ico.ico; DestDir: {app}; Flags: ignoreversion
; Примечание: Не используйте "Flags: ignoreversion" для системных файлов
Source: {app}\*; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs;

[Icons]
Name: {group}\{#MyAppName}; Filename: {app}\{#MyAppExeName}; Components: DDU\I; Tasks: icons\group; IconFilename: {app}\ico.ico;
Name: {group}\{cm:UninstallProgram,{#MyAppName}}; Filename: {uninstallexe}; Components: DDU\I; Tasks: icons\group; IconFilename: {app}\ico.ico;
Name: {group}\{cm:ProgramOnTheWeb,{#MyAppName}}; Filename: {#MyAppURL}; Components: DDU\I; Tasks: icons\group;
Name: {commondesktop}\{#MyAppName}; Filename: {app}\{#MyAppExeName}; Components: DDU\I; Tasks: icons\desktop; IconFilename: {app}\ico.ico;
Name: {userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}; Filename: {app}\{#MyAppExeName}; Components: DDU\I; Tasks: icons\quicklaunchicon; IconFilename: {app}\ico.ico;

[Run]
Filename: {app}\{#MyAppExeName}; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait skipifsilent PostInstall Unchecked;

[ Code]
#ifdef UNICODE
#define A "W"
#else
#define A "A"
#endif

const
///////////////////////////////////Относится к лого и изображениям мастера
RT_RCDATA = 10;
LOAD_LIBRARY_AS_DATAFILE = $2;

var
///////////////////////////////////Лого и изображения
lPLogo, bPicHandle, bPicHandle2, lPicHandle: THandle;
BtnImage: TBitmapImage;
///////////////////////////////////////////
iInitialize: Boolean;


///////////////////////////////////Ресурсы(относится к лого и изображениям мастера)
function GetFromRes(const ResName, SaveFileName: String): Boolean;
var
lResStream: TResourceStream;
begin
lResStream := TResourceStream.Create(HInstance, ResName, RT_RCDATA);
try
lResStream.SaveToFile(AddBackslash(ExpandConstant('{tmp}')) + SaveFileName);
finally
lResStream.Free;
Result := FileExists(AddBackslash(ExpandConstant('{tmp}')) + SaveFileName);
end;
end;

function OnShouldSkipPage(Sender: TWizardPage): Boolean;
begin
if WizardForm.ComponentsList.Items.Count > 0 then WizardForm.Tag:= 1; // отображаются страницы выбора папки и компонентов
end;

procedure InitializeWizard;
begin
PageFromID(wpSelectDir).OnShouldSkipPage:= @OnShouldSkipPage
with WizardForm do
begin

///////////////////////////////////Логотип и изображения мастера
iInitialize := True;
if GetFromRes('_IS_BOTVA', 'botva2.dll') and GetFromRes('_IS_B2P', 'b2p.dll') and GetFromRes('_IS_LOGO', 'logo.png') and GetFromRes('_IS_BPIC', 'bPic.png') and GetFromRes('_IS_LIPIC', 'LiPic.png') and GetFromRes('_IS_APIC', 'aPic.png') then
begin
///////////////////////////////////Изображения
bPicHandle := ImgLoad(WelcomePage.Handle, ExpandConstant('{tmp}\aPic.png'), WizardBitmapImage.Left, WizardBitmapImage.Top, WizardBitmapImage.Width, WizardBitmapImage.Height, True, True);
WizardBitmapImage.Hide;
ImgSetVisibility(bPicHandle, True);
ImgApplyChanges(WelcomePage.Handle);

bPicHandle := ImgLoad(FinishedPage.Handle, ExpandConstant('{tmp}\bPic.png'), WizardBitmapImage2.Left, WizardBitmapImage2.Top, WizardBitmapImage2.Width, WizardBitmapImage2.Height, True, True);
WizardBitmapImage2.Hide;
ImgSetVisibility(bPicHandle, True);
ImgApplyChanges(FinishedPage.Handle);

lPicHandle := ImgLoad(MainPanel.Handle, ExpandConstant('{tmp}\LiPic.png'), WizardSmallBitmapImage.Left, WizardSmallBitmapImage.Top, WizardSmallBitmapImage.Width, WizardSmallBitmapImage.Height, True, True);
WizardSmallBitmapImage.Hide;
DiskSpaceLabel.Hide;
ComponentsDiskSpaceLabel.Hide;
ImgSetVisibility(lPicHandle, True);
ImgApplyChanges(MainPanel.Handle);
////////////////////////////////////////////

///////////////////////////////////Логотип

lPLogo:= ImgLoad(WizardForm.Handle, ExpandConstant('{tmp}\logo.png'), ScaleX(20), ScaleY(318), ScaleX(124), ScaleY(40), True, True);
ImgApplyChanges(WizardForm.Handle);
end;

///////////////////////////////////WinTB
ExtractTemporaryFile('WinTB.dll');
SetTaskBarProgressValue(0, 60);
SetTaskBarProgressState(0, TBPF_ERROR);
TaskBarV10(MainForm.Handle, WizardForm.Handle, false, false, 0, 0, _m_);
//////////////////////////////////////

with TLabel.Create(WizardForm) do
begin
Parent:=WizardForm;
AutoSize:=False;
Transparent:= true;
SetBounds(ScaleX(20), ScaleY(318), ScaleX(124), ScaleY(40));
end;
end;
end;

function LoadLibraryEx(lpFileName: String; hFile: THandle; dwFlags: DWORD): THandle; external 'LoadLibraryExA@kernel32.dll stdcall';
function LoadString(hInstance: THandle; uID: SmallInt; var lpBuffer: Byte; nBufferMax: Integer): Integer; external 'LoadStringA@user32.dll stdcall';
function PinToTaskbarWin7(Filename: String): Boolean;
var
hInst: THandle;
buf: array [0..255] of byte;
i: byte;
strVerb, s: String;
objShell, colverbs: Variant;
begin
if not FileExists(Filename) then Exit;
if (GetWindowsVersion shr 24 = 6) and ((GetWindowsVersion shr 16) and $FF = 1) then
begin
hInst := LoadLibraryEx(ExpandConstant('{sys}\shell32.dll'), 0, LOAD_LIBRARY_AS_DATAFILE);
for i := 0 to LoadString(hInst, 5386, buf[0], 255)-1 do strVerb := strVerb + Chr(Buf[i]);
FreeDLL(hInst);
try
objShell := CreateOleObject('Shell.Application');
except
ShowExceptionMessage;
Exit;
end;
colVerbs := objShell.Namespace(ExtractFileDir(Filename)).ParseName(ExtractFileName(Filename)).Verbs;
for i := colVerbs.Count downto 1 do if colVerbs.Item[i].Name = strVerb then
begin
colVerbs.Item[i].DoIt;
Result := True;
end;
end;
end;

procedure CurStepChanged(CurStep: TSetupStep);
var
res:Integer;
s,s1:string;
begin
If CurStep=ssPostInstall
then
begin
s1:=ExpandConstant('{app}');
Exec(s, '-y -o"'+ s1 + '"', '', SW_SHOWNORMAL, ewWaitUntilTerminated, res);

if (CurStep = ssPostInstall) and IsTaskSelected('icons\taskbaricon') then PinToTaskbarWin7(ExpandConstant('{app}\{#MyAppExeName}'))
end;
end;

Procedure CurPageChanged(CurPageID: Integer);
Begin
Case CurPageID of
wpSelectTasks:
if IsComponentSelected('DDU\I') then
begin
WizardForm.NextButton.Caption:= SetupMessage(msgButtonInstall);
end;
wpSelectDir: if WizardForm.Tag = 1 then

begin
WizardForm.SelectDirPage.Notebook.ActivePage:= WizardForm.SelectComponentsPage;
WizardForm.PageNameLabel.Caption:= SetupMessage(msgWizardSelectComponents);
WizardForm.Hint:= WizardForm.PageDescriptionLabel.Caption; // запомнить SetupMessage(msgSelectDirDesc)
WizardForm.PageDescriptionLabel.Caption:= SetupMessage(msgSelectComponentsDesc);
end;
wpSelectComponents: if WizardForm.Tag = 1 then
begin
WizardForm.SelectComponentsPage.Notebook.ActivePage:= WizardForm.SelectDirPage;
WizardForm.DiskSpaceLabel.Caption:= WizardForm.ComponentsDiskSpaceLabel.Caption;
WizardForm.PageNameLabel.Caption:= SetupMessage(msgWizardSelectDir);
WizardForm.PageDescriptionLabel.Caption:= WizardForm.Hint; // иначе вместо названия программы [name]
if IsComponentSelected('DDU\I') then
begin
WizardForm.DirEdit.Text :=(ExpandConstant('{#SetupSetting("DefaultDirName")}'))
end else
if IsComponentSelected('DDU\P') then
begin
WizardForm.DirEdit.Text := AddBackslash(ExpandConstant('{src}')) + '{#MyAppName} Portable'
WizardForm.NextButton.Caption:= SetupMessage(msgButtonInstall);
end;
end;
end;
end;

procedure DeinitializeSetup();
begin
if iInitialize then
begin
gdipShutdown;
TaskBarDestroy;
end;
end;

procedure InitializeUninstallProgressForm;
begin
with UninstallProgressForm do
begin
///////////////////////////////////Логотип и изображения мастера
if GetFromRes('_IS_BOTVA', 'botva2.dll') and GetFromRes('_IS_B2P', 'b2p.dll') and GetFromRes('_IS_LOGO', 'logo.png') and GetFromRes('_IS_LIPIC', 'LIPic.png') then
begin
///////////////////////////////////Изображения
lPicHandle := ImgLoad(MainPanel.Handle, ExpandConstant('{tmp}\LiPic.png'), WizardSmallBitmapImage.Left, WizardSmallBitmapImage.Top, WizardSmallBitmapImage.Width, WizardSmallBitmapImage.Height, True, True);
WizardSmallBitmapImage.Hide;
ImgSetVisibility(lPicHandle, True);
ImgApplyChanges(MainPanel.Handle);

///////////////////////////////////Логотип
lPLogo:= ImgLoad(UninstallProgressForm.Handle, ExpandConstant('{tmp}\logo.png'), ScaleX(20), ScaleY(318), ScaleX(124), ScaleY(40), True, True);
ImgApplyChanges(UninstallProgressForm.Handle);
end;

with TLabel.Create(nil) do
begin
Parent:=UninstallProgressForm;
AutoSize:=False;
Transparent:= true;
SetBounds(ScaleX(20), ScaleY(318), ScaleX(124), ScaleY(40));
end;
end;
end;

procedure DeinitializeUninstall();
begin
if iInitialize then gdipShutdown;
end;

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

Dodakaedr
28-06-2014, 23:57
habib2302, и модули с dll-ками тоже.

habib2302
29-06-2014, 00:00
Dodakaedr, https://yadi.sk/d/aOOMnzcaVGBvn

Dodakaedr
29-06-2014, 00:13
habib2302, Так у вас ж работает смена пути в зависимости от типа установки

habib2302
29-06-2014, 00:16
Dodakaedr, я знаю, но почему не работает команда /DIR




© OSzone.net 2001-2012