#define MyAppName "VirtualDub"
#define MyAppVersion "5.0.7.39"
#define MyAppExeName "Veedub64.exe"
[Setup]
AppName={#MyAppName}
AppVersion={#MyAppVersion}
DefaultDirName={code:GetInstallDir|{pf}\{#MyAppName}}
DefaultGroupName={#MyAppName}
DirExistsWarning=no
ArchitecturesAllowed=x86 x64
ArchitecturesInstallIn64BitMode=x64
//==============================================================//
SolidCompression=yes
Compression=lzma/ultra64
InternalCompressLevel=Ultra64
LZMABlockSize=262144
LZMADictionarySize=65536
LZMAMatchFinder=BT
LZMANumFastBytes=273
MergeDuplicateFiles=yes
//==============================================================//
Uninstallable=not PortableCheck
CreateUninstallRegKey=not PortableCheck
//==============================================================//
[Files]
Source: "InstallFiles\*"; Flags: dontcopy;
;Source: "VirtualDub\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Check:InstallerCheck;
;Source: "VirtualDubPortable\*"; DestDir: "{commondesktop}\VirtualDubPortable"; Flags: ignoreversion recursesubdirs createallsubdirs;Check: PortableCheck;
Source: C:\Users\Vitaly\Desktop\111\Veedub64eng.exe; DestDir: {app}; Check: InstallerCheck and Eng;
Source: C:\Users\Vitaly\Desktop\111\Veedub64rus.exe; DestDir: {app}; Check: InstallerCheck and Rus;
Source: C:\Users\Vitaly\Desktop\111\Veedub64engportable.exe; DestDir: {userdesktop}\VirtualDub Portable; Check: PortableCheck and Eng;
Source: C:\Users\Vitaly\Desktop\111\Veedub64rusportable.exe; DestDir: {userdesktop}\VirtualDub Portable; Check: PortableCheck and Rus;
//==============================================================//
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" ; Check:InstallerCheck and GroupIconsCheck;
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"; Check:InstallerCheck and GroupIconsCheck;
Name: "{commondesktop}\Ярлык(и) на «Рабочем столе"; Filename: "{app}\{#MyAppExeName}"; WorkingDir: {app}; Check:InstallerCheck and DesktopIconsCheck;
;Name: "{commondesktop}\Ярлыки в меню «Пуск»"; Filename: "{app}\{#MyAppExeName}"; Check:InstallerCheck and GroupIconsCheck;
;Name: "{commondesktop}\Ярлык в панели задач"; Filename: "{app}\{#MyAppExeName}"; Check:InstallerCheck and TaskBarIconsCheck;
;Name: "{commondesktop}\Закрепить в меню «Пуск»"; Filename: "{app}\{#MyAppExeName}"; Check:InstallerCheck and StartMenuIconsCheck;
[code_]
//==============================================================//
#include "Modules\botva2.iss"
//==============================================================//
var
ComponentsPage: TWizardPage;
InstallerAndPortable, Icons,Lang: TNewGroupBox;
Installer,Portable,En,Ru: TNewRadioButton;
DesktopIcons,GroupIcons,TaskBarIcons,StartMenuIcons: TNewCheckBox;
InstallerPanel,PortablePanel: TPanel;
InstallerImage,PortableImage: Longint;
//==============================================================//
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}\Installer.png')) then ExtractTemporaryFile('Installer.png');
if not FileExists(ExpandConstant('{tmp}\Portable.png')) then ExtractTemporaryFile('Portable.png');
Result := True;
end;
//==============================================================//
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 GetInstallDir(S: String): String;
begin
if CheckParam('/P') then
Result:= ExpandConstant('{userdesktop}\VirtualDub Portable')
else
Result:= ExpandConstant(S);
end;
//==============================================================//
function PortableCheck: Boolean;
begin
Result := Portable.Checked or CheckParam('/P');
end;
//==============================================================//
function InstallerCheck: Boolean;
begin
Result := Installer.Checked or CheckParam('/I');
end;
//==============================================================//
function DesktopIconsCheck: Boolean;
begin
Result:= DesktopIcons.Checked;
end;
//==============================================================//
function GroupIconsCheck: Boolean;
begin
Result:= GroupIcons.Checked;
end;
//==============================================================//
function TaskBarIconsCheck: Boolean;
begin
Result:= TaskBarIcons.Checked;
end;
//==============================================================//
function StartMenuIconsCheck: Boolean;
begin
Result:= StartMenuIcons.Checked;
end;
//==============================================================//
function Eng: Boolean;
begin
Result := (En.Checked and not CheckParam('/Ru')) or CheckParam('/En'));
end;
//==============================================================//
function Rus: Boolean;
begin
Result := (Ru.Checked and not CheckParam('/En')) or (CheckParam('/Ru'));
end;
//==============================================================//
procedure CopmpClick(Sender: TObject);
begin
case TNewRadioButton(Sender) of
Installer:
begin
DesktopIcons.Checked:=True;
DesktopIcons.Enabled:= DesktopIcons.Checked;
GroupIcons.Checked:=True;
GroupIcons.Enabled:= GroupIcons.Checked;
PortablePanel.Hide;
TaskBarIcons.Checked:=False;
TaskBarIcons.Enabled:= True;
StartMenuIcons.Checked:=False;
StartMenuIcons.Enabled:= True;
WizardForm.DirEdit.Text := AddBackslash(ExpandConstant('{pf}')) + '{#MyAppName}';
end;
Portable:
begin
PortablePanel.Show;
DesktopIcons.Checked:=False;
DesktopIcons.Enabled:= DesktopIcons.Checked;
GroupIcons.Checked:=False;
GroupIcons.Enabled:= GroupIcons.Checked;
TaskBarIcons.Checked:=False;
TaskBarIcons.Enabled:= TaskBarIcons.Checked;
StartMenuIcons.Checked:=False;
StartMenuIcons.Enabled:= StartMenuIcons.Checked;
WizardForm.DirEdit.Text := AddBackslash(ExpandConstant('{userdesktop}')) + '{#MyAppName} Portable';
end;
end;
end;
//==============================================================//
procedure InitializeWizard();
begin
//==============================================================//
ComponentsPage:= CreateCustomPage(wpWelcome, 'Выбор компонентов', 'Какие компоненты должны быть установлены?');
//==============================================================//
InstallerAndPortable:=TNewGroupBox.Create(WizardForm);
InstallerAndPortable.Parent := ComponentsPage.Surface;
InstallerAndPortable.Left := ScaleX(10);
InstallerAndPortable.Top := ScaleY(10);
InstallerAndPortable.Width := ScaleX(205);
InstallerAndPortable.Height := ScaleY(62);
InstallerAndPortable.Caption := 'Пожалуйста, выберите версию:';
//==============================================================//
Icons:=TNewGroupBox.Create(WizardForm);
Icons.Parent := ComponentsPage.Surface;
Icons.Left := ScaleX(10);
Icons.Top := ScaleY(70);
Icons.Width := ScaleX(205);
Icons.Height := ScaleY(105);
Icons.Caption := 'Ярлыки:';
//==============================================================//
//==============================================================//
Lang:=TNewGroupBox.Create(WizardForm);
Lang.Parent := ComponentsPage.Surface;
Lang.Left := ScaleX(10);
Lang.Top := ScaleY(175);
Lang.Width := ScaleX(205);
Lang.Height := ScaleY(60);
Lang.Caption := 'Выбор языка программы:';
//==============================================================//
InstallerPanel:= TPanel.Create(WizardForm);
InstallerPanel.Parent := ComponentsPage.Surface;
InstallerPanel.Left := ScaleX(236);
InstallerPanel.Top := ScaleY(16);
InstallerPanel.Width := ScaleX(180);
InstallerPanel.Height := ScaleY(180);
InstallerPanel.BevelOuter := bvNone;
//==============================================================//
PortablePanel:= TPanel.Create(WizardForm);
PortablePanel.Parent := ComponentsPage.Surface;
PortablePanel.Left := ScaleX(236);
PortablePanel.Top := ScaleY(16);
PortablePanel.Width := ScaleX(180);
PortablePanel.Height := ScaleY(180);
PortablePanel.BevelOuter := bvNone;
//==============================================================//
Installer:=TNewRadioButton.Create(WizardForm);
Installer.Parent :=InstallerAndPortable;
Installer.Left := ScaleX(8);
Installer.Top := ScaleY(15);
Installer.Width := ScaleX(170);
Installer.Height := ScaleY(17);
Installer.Caption := 'Установка обычной версий';
Installer.Checked := not CheckParam('/P');
Installer.OnClick:=@CopmpClick;
//==============================================================//
Portable:=TNewRadioButton.Create(WizardForm);
Portable.Parent := InstallerAndPortable;
Portable.Left := ScaleX(8);
Portable.Top := ScaleY(35);
Portable.Width := ScaleX(190);
Portable.Width := ScaleX(190);
Portable.Caption := 'Установка портативной версии';
Portable.Checked := CheckParam('/P');
Portable.OnClick:=@CopmpClick;
//==============================================================//
DesktopIcons:=TNewCheckBox.Create(WizardForm);
DesktopIcons.Parent := Icons;
DesktopIcons.Left := ScaleX(8);
DesktopIcons.Top := ScaleY(20);
DesktopIcons.Width := ScaleX(185);
DesktopIcons.Height := ScaleY(17);
DesktopIcons.Caption := 'Ярлык(и) на «Рабочем столе';
DesktopIcons.Checked:=true;
//==============================================================//
GroupIcons:=TNewCheckBox.Create(WizardForm);
GroupIcons.Parent := Icons;
GroupIcons.Left := ScaleX(8);
GroupIcons.Top := ScaleY(40);
GroupIcons.Width := ScaleX(161);
GroupIcons.Height := ScaleY(17);
GroupIcons.Caption := 'Ярлыки в меню «Пуск»';
GroupIcons.Checked:=true;
//==============================================================//
TaskBarIcons:=TNewCheckBox.Create(WizardForm);
TaskBarIcons.Parent := Icons;
TaskBarIcons.Left := ScaleX(8);
TaskBarIcons.Top := ScaleY(60);
TaskBarIcons.Width := ScaleX(137);
TaskBarIcons.Height := ScaleY(17);
TaskBarIcons.Caption := 'Ярлык в панели задач';
//==============================================================//
StartMenuIcons:=TNewCheckBox.Create(WizardForm);
StartMenuIcons.Parent := Icons;
StartMenuIcons.Left := ScaleX(8);
StartMenuIcons.Top := ScaleY(80);
StartMenuIcons.Width := ScaleX(153);
StartMenuIcons.Height := ScaleY(17);
StartMenuIcons.Caption := 'Закрепить в меню «Пуск»';
//==============================================================//
//==============================================================//
En:=TNewRadioButton.Create(WizardForm);
En.Parent :=Lang;
En.Left := ScaleX(8);
En.Top := ScaleY(15);
En.Width := ScaleX(170);
En.Height := ScaleY(17);
En.Caption := 'Английская версия программы';
//==============================================================//
Ru:=TNewRadioButton.Create(WizardForm);
Ru.Parent := Lang;
Ru.Left := ScaleX(8);
Ru.Top := ScaleY(35);
Ru.Width := ScaleX(190);
Ru.Width := ScaleX(190);
Ru.Caption := 'Русская версия программы';
Ru.Checked := True;
//==============================================================//
InstallerImage:=ImgLoad(InstallerPanel.Handle,ExpandConstant('{tmp}\Installer.png'),ScaleX(0),ScaleY(0),ScaleX(178),ScaleY(178),False,False);
ImgApplyChanges(InstallerPanel.Handle);
//==============================================================//
PortableImage:=ImgLoad(PortablePanel.Handle,ExpandConstant('{tmp}\Portable.png'),ScaleX(0),ScaleY(0),ScaleX(180),ScaleY(180),False,False);
ImgApplyChanges(PortablePanel.Handle);
//==============================================================//
end;
//=======================================================================================================================================================================//
//=======================================================================================================================================================================//
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, 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.Name, strVerb) = 0 then
begin
colVerbs.Item.DoIt;
Result := True;
Break;
end;
except
Exit;
end;
finally
FreeDLL(hInst);
end;
end;
//=======================================================================================================================================================================//
procedure TaskbarStartMenu(CurPageID: integer);
begin
case CurPageID of
wpFinished: begin
if TaskBarIcons.Checked then
PinToTaskbar(WizardDirValue + '\{#MyAppExeName}', True, True);
if StartMenuIcons.Checked then
PinToTaskbar(WizardDirValue + '\{#MyAppExeName}', False, True);
end;
end;
end;
//=======================================================================================================================================================================//
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
instPath: string;
begin
if RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#SetupSetting("AppName")}_is1',
'InstallLocation', instPath) then begin
case CurUninstallStep of
usUninstall: begin
PinToTaskbar(instPath + '\{#MyAppExeName}', True, False);
PinToTaskbar(instPath + '\{#MyAppExeName}', False, False);
end;
end;
end;
end;
//=======================================================================================================================================================================//
Procedure HideComponents();
begin
PortablePanel.Hide;
InstallerPanel.Hide;
end;
//=======================================================================================================================================================================//
Procedure ShowComponents(CurPageID: Integer);
begin
Case CurPageID of
ComponentsPage.ID:
begin
InstallerPanel.Show;
end;
end;
end;
//=======================================================================================================================================================================//
function ShouldSkipPage(PageID: Integer): Boolean;
begin
if Portable.Checked then
begin
if (PageID = 8) then
Result:= True;
end;
end;
//=======================================================================================================================================================================//
procedure CurPageChanged(CurPageID: Integer);
begin
TaskbarStartMenu(CurPageID);
HideComponents;
ShowComponents(CurPageID);
end;
//=======================================================================================================================================================================//
procedure DeinitializeSetup();
begin
gdipShutdown;
end;
//=======================================================================================================================================================================//