Ветеран
Сообщения: 862
Благодарности: 102
|
Профиль
|
Отправить PM
| Цитировать
доброе время суток.помогите мне объединить 2 скрипта
читать дальше »
Код: 
[.......Code]
#ifdef UNICODE
#define A "W"
#else
#define A "A"
#endif
const
///////////////////////////////////Относится к лого и изображениям мастера
RT_RCDATA = 10;
///////////////////////////////////Удаление других приложений при старте
APPID_AIDA_EXTREME = 'AIDA64 Extreme Edition';
APPID_AIDA_BUISNES = 'AIDA64 Business Edition';
WAIT_OBJECT_0 = $0;
STARTF_USESHOWWINDOW = 1;
NORMAL_PRIORITY_CLASS = $00000020;
INFINITE = $FFFFFFFF;
type
///////////////////////////////////Удаление других приложений при старте
_STARTUPINFO = record
cb: DWORD;
#ifdef UNICODE
lpReserved, lpDesktop, lpTitle: PAnsiChar;
#else
lpReserved, lpDesktop, lpTitle: PChar;
#endif
dwX, dwY, dwXSize, dwYSize, dwXCountChars, dwYCountChars, dwFillAttribute, dwFlags: DWORD;
wShowWindow, cbReserved2: Word;
lpReserved2: Byte;
hStdInput, hStdOutput, hStdError: THandle;
end;
_PROCESS_INFORMATION = record
hProcess: THandle;
hThread: THandle;
dwProcessId: DWORD;
dwThreadId: DWORD;
end;
//////////////////////////////
///////////////////////////////////Удаление других приложений при старте
function CloseHandle(hObject: THandle): BOOL; external 'CloseHandle@kernel32.dll stdcall';
function WaitForSingleObject(hHandle: THandle; dwMilliseconds: DWORD): DWORD; external 'WaitForSingleObject@kernel32.dll stdcall';
#ifdef UNICODE
function CreateProcess(lpApplicationName, lpCommandLine: PAnsiChar; lpProcessAttributes, lpThreadAttributes: Longint; bInheritHandles: BOOL; dwCreationFlags: DWORD; lpEnvironment, lpCurrentDirectory: PAnsiChar; const lpStartupInfo: _STARTUPINFO; var lpProcessInformation: _PROCESS_INFORMATION): BOOL; external 'CreateProcess{#A}@kernel32.dll stdcall';
#else
function CreateProcess(lpApplicationName, lpCommandLine: PChar; lpProcessAttributes, lpThreadAttributes: Longint; bInheritHandles: BOOL; dwCreationFlags: DWORD; lpEnvironment, lpCurrentDirectory: PChar; const lpStartupInfo: _STARTUPINFO; var lpProcessInformation: _PROCESS_INFORMATION): BOOL; external 'CreateProcess{#A}@kernel32.dll stdcall';
#endif
///////////////////////////////
var
///////////////////////////////////Дерево выбора папок
TDV: TFolderTreeView;
TFV: TStartMenuFolderTreeView;
ResultCode: Integer;
///////////////////////////////////Лого и изображения
lPLogo, bPicHandle, bPicHandle2, lPicHandle: THandle;
BtnImage: TBitmapImage;
///////////////////////////////////////////
CheckLicense: TCheckBox;
iInitialize: Boolean;
///////////////////////////////////WinTB
TB: TTrackBar;
///////////////////////////////
///////////////////////////////////Удаление других приложений при старте
function GetUninstallPath(const AppIds: array of String): array of String;
var
StringList: TStringList;
i, Len: Integer;
Buff: String;
begin
for i := 0 to GetArrayLength(AppIds)-1 do
begin
Buff := RemoveQuotes(ExpandConstant('{reg:HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' + AppIds[i] + '_is1,UninstallString|}'));
if Buff <> '' then
begin
Len := GetArrayLength(Result);
SetArrayLength(Result, Len+1);
Result[Len] := Buff;
end;
end;
end;
///////////////////////////////////Удаление других приложений при старте
procedure UninstallApps(const UninstallPathes: array of String);
var
pi: _PROCESS_INFORMATION;
si: _STARTUPINFO;
i: Integer;
begin
for i := 0 to GetArrayLength(UninstallPathes)-1 do
begin
si.cb := SizeOf(si);
si.dwFlags := STARTF_USESHOWWINDOW;
si.wShowWindow := SW_SHOWNORMAL;
#ifdef UNICODE
if not CreateProcess('', PAnsiChar(UninstallPathes[i]), 0, 0, False, NORMAL_PRIORITY_CLASS, '', '', si, pi) then
#else
if not CreateProcess('', PChar(UninstallPathes[i]), 0, 0, False, NORMAL_PRIORITY_CLASS, '', '', si, pi) then
#endif
begin
MsgBox(SysErrorMessage(DLLGetLastError), mbCriticalError, MB_OK);
Exit;
end;
try
while WaitForSingleObject(pi.hProcess, INFINITE) <> WAIT_OBJECT_0 do Application.ProcessMessages;
finally
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
end;
end;
end;
//////////////////////////////////////////
function MessageBox(hWnd: Integer; lpText, lpCaption: PAnsiChar; uType: Cardinal): Integer;
external 'MessageBoxA@user32.dll stdcall';
procedure TBOnChange(Sender: TObject);
begin
SetTaskBarProgressValue(WizardForm.Handle, TTrackBar(sender).Position);
end;
///////////////////////////////////Ресурсы(относится к лого и изображениям мастера)
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 InitializeSetup:boolean;
///////////////////////////////////Удаление других приложений при старте
var
i, Len: Integer;
uArray: array of String;
begin
uArray := GetUninstallPath( ['{#SetupSetting("AppID")}', APPID_AIDA_EXTREME, APPID_AIDA_BUISNES] );
Len := GetArrayLength(uArray);
Result := Len = 0;
if not Result then if MsgBox('Перед установкой необходимо удалить все старые версии приложения, вызвать программы удаления сейчас?', mbError, MB_YESNO) = IDYES then
begin
UninstallApps(uArray);
Result := InitializeSetup();
end;
/////////////////////////////////////
end;
///////////////////////////////////Обработчик чекбокса лицензионного соглашения
procedure LicenseOnClick(Sender: TObject);
begin
case TCheckBox(Sender).Checked of
True: WizardForm.LicenseAcceptedRadio.Checked := True;
False: WizardForm.LicenseNotAcceptedRadio.Checked := True;
end;
end;
//////////////////////////
///////////////////////////////////Дерево выбора папки установки
procedure TDVOnChange(Sender: TObject);
begin
if IsComponentSelected('AIDA641') then
WizardForm.DirEdit.Text:= AddBackslash(TDV.Directory)+'{#AIDA641}'
else
if IsComponentSelected('AIDA642') then
WizardForm.DirEdit.Text:= AddBackslash(TDV.Directory)+'{#AIDA642}';
end;
////////////////////////////////
///////////////////////////////////Дерево выбора папки программ
procedure TFVOnChange(Sender: TObject);
begin
if IsComponentSelected('AIDA641') then
WizardForm.GroupEdit.Text:= AddBackslash(TFV.Directory)+'{#AIDA641}'
else
if IsComponentSelected('AIDA642') then
WizardForm.GroupEdit.Text:= AddBackslash(TFV.Directory)+'{#AIDA642}';
end;
//////////////////
///////////////////////////////////Смена страниц местами
function OnShouldSkipPage(Sender: TWizardPage): Boolean;
begin
if WizardForm.ComponentsList.Items.Count > 0 then WizardForm.Tag:= 1; // отображаются страницы выбора папки и компонентов
end;
//////////////////
procedure RedesignWizardForm;
begin
with WizardForm.ComponentsList do
begin
Top := ScaleY(50);
Height := ScaleY(155);
end;
end;
procedure InitializeWizard;
begin
RedesignWizardForm;
WizardForm.TypesCombo.hide;
///////////////////////////////////Смена страниц местами
PageFromID(wpSelectDir).OnShouldSkipPage:= @OnShouldSkipPage;
/////////////////
WizardForm.LicenseNotAcceptedRadio.Hide;
WizardForm.LicenseAcceptedRadio.Hide;
WizardForm.LicenseMemo.Height := ScaleY(175);
CheckLicense:= TCheckBox.Create(WizardForm);
CheckLicense.Left:= ScaleX(0);
CheckLicense.Top:= ScaleY(216);
CheckLicense.Caption:= WizardForm.LicenseAcceptedRadio.Caption;
CheckLicense.Width:= ScaleX(417);
CheckLicense.OnClick:= @LicenseOnClick;
CheckLicense.Parent:= WizardForm.LicensePage;
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;
ImgSetVisibility(lPicHandle, True);
ImgApplyChanges(MainPanel.Handle);
////////////////////////////////////////////
///////////////////////////////////Логотип
lPLogo:= ImgLoad(WizardForm.Handle, ExpandConstant('{tmp}\logo.png'), ScaleX(20), ScaleY(320), ScaleX(126), ScaleY(38), True, True);
ImgApplyChanges(WizardForm.Handle);
end;
///////////////////////////////////
///////////////////////////////////WinTB
WizardForm.Position:=poScreenCenter;
WizardForm.BorderIcons:=[biSystemMenu];
ExtractTemporaryFile('WinTB.dll');
TaskBarV11(WizardForm.Handle);
TB:=TTrackBar.Create(Wizardform)
//////////////////////////////////////
TDV:= TFolderTreeView.Create(WizardForm);
TDV.Top:= WizardForm.DirEdit.Top+28;
TDV.Width:= 417;
TDV.Height:= 100;
TDV.OnChange:= @TDVOnChange;
TDV.Parent:= WizardForm.SelectDirPage;
TFV:= TStartMenuFolderTreeView.Create(nil);
TFV.Top:= WizardForm.GroupEdit.Top+28;
TFV.Width:= 417;
TFV.Height:= 100;
TFV.SetPaths(ExpandConstant('{userprograms}'),ExpandConstant('{commonprograms}'),ExpandConstant('{userstartup}'),ExpandConstant('{commonstartup}'));
TFV.OnChange:= @TFVOnChange;
TFV.Parent:= WizardForm.SelectProgramGroupPage;
with TLabel.Create(WizardForm) do
begin
Parent:=WizardForm;
AutoSize:=False;
Transparent:= true;
SetBounds(ScaleX(20), ScaleY(320), ScaleX(126), ScaleY(38));
end;
end;
end;
///////////////////////////////////WinTB
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
Confirm:=false; Cancel:=false;
WizardForm.ProgressGauge.State:=npbsPaused;
case MessageBox(WizardForm.Handle, SetupMessage(msgExitSetupMessage), SetupMessage(msgExitSetupTitle), MB_YESNO or MB_DEFBUTTON2 or MB_ICONINFORMATION) of
IDYES: Cancel:=true;
IDNO: begin WizardForm.BringToFront; WizardForm.ProgressGauge.State:=npbsNormal; end;
end;
end;
//////////////////////////////////////
Procedure CurPageChanged(CurPageID: Integer);
Begin
///////////////////////////////////Смена страниц местами
Case CurPageID of
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('AIDA641') then
begin
WizardForm.DirEdit.Text := AddBackslash(ExpandConstant('{#SetupSetting("DefaultDirName")}')) + '{#AIDA641}';
WizardForm.GroupEdit.Text := AddBackslash(ExpandConstant('{#SetupSetting("DefaultGroupName")}')) + '{#AIDA641}';
end else
if IsComponentSelected('AIDA642') then
begin
WizardForm.DirEdit.Text := AddBackslash(ExpandConstant('{#SetupSetting("DefaultDirName")}')) + '{#AIDA642}'
WizardForm.GroupEdit.Text := AddBackslash(ExpandConstant('{#SetupSetting("DefaultGroupName")}')) + '{#AIDA642}'
end;
end;
///////////////////////////////////////////////////////
wpSelectTasks:
begin
WizardForm.NextButton.Caption:= SetupMessage(msgButtonInstall);
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(320), ScaleX(126), ScaleY(38), True, True);
ImgApplyChanges(UninstallProgressForm.Handle);
end;
with TLabel.Create(nil) do
begin
Parent:=UninstallProgressForm;
AutoSize:=False;
Transparent:= true;
SetBounds(ScaleX(20), ScaleY(320), ScaleX(126), ScaleY(38));
end;
end;
end;
procedure DeinitializeUninstall();
begin
gdipShutdown;
end;
Код: 
[.....code]
#include "WinTB.iss"
function MessageBox(hWnd: Integer; lpText, lpCaption: PAnsiChar; uType: Cardinal): Integer;
external 'MessageBoxA@user32.dll stdcall';
procedure TBOnChange(Sender: TObject);
begin
SetTaskBarProgressValue(WizardForm.Handle, TTrackBar(sender).Position);
end;
procedure InitializeWizard(); var TB: TTrackBar;
begin
WizardForm.Position:=poScreenCenter;
WizardForm.BorderIcons:=[biSystemMenu];
ExtractTemporaryFile('WinTB.dll');
TaskBarV11(WizardForm.Handle);
TB:=TTrackBar.Create(Wizardform)
end;
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
Confirm:=false; Cancel:=false;
WizardForm.ProgressGauge.State:=npbsPaused;
case MessageBox(WizardForm.Handle, SetupMessage(msgExitSetupMessage), SetupMessage(msgExitSetupTitle), MB_YESNO or MB_DEFBUTTON2 or MB_ICONINFORMATION) of
IDYES: Cancel:=true;
IDNO: begin WizardForm.BringToFront; WizardForm.ProgressGauge.State:=npbsNormal; end;
end;
end;
procedure DeinitializeSetup();
begin
TaskBarDestroy;
end;
просто после объединения и компилирования вот что у меня получается
 
|