Drez
Newbie | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Есть скрипт новой страницы инно [Setup] AppName=Already Installed Page AppVerName=Already Installed Page 1.0 CreateAppDir=no Uninstallable=no [Code] var StaticText: TNewStaticText; RadioButton_1,RadioButton_2: TRadioButton; Uninstall,Location:string; ResultCode:Integer; //Процедура NextButtonClick для новой страницы. function Page_NextButtonClick(Page: TWizardPage): Boolean; begin if RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\My Program_is1','UninstallString', Uninstall) then Uninstall:=RemoveQuotes(Uninstall); if RadioButton_1.Checked then begin if not Exec(Uninstall, ' /SILENT', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then MsgBox('Ошибка удаления. ' #13#13 '' + SysErrorMessage(ResultCode) + '.' #13#13 'Вероятно, деинсталлятор был перемещен, удален или переименован.', mbError, MB_OK); Result:=True; end else begin if not RadioButton_1.Checked then Result:=True; end; end; //Процедура CancelButtonClick для новой страницы. procedure Page_CancelButtonClick(Page: TWizardPage; var Cancel, Confirm: Boolean); begin Confirm:=False; Cancel:=True; end; //Эта процедура создает новую страницу и все что на нее находится function CheckInstalledPage(PreviousPageId: Integer): Integer; var Page: TWizardPage; begin RegQueryStringValue(HKLM, 'Software\Microsoft\Windows\CurrentVersion\Uninstall\My Program_is1','InstallLocation', Location) Page := CreateCustomPage(PreviousPageId,'Previous Installation Found','Please choose how you want to proceed.'); //Текст на странице StaticText := TNewStaticText.Create(Page); StaticText.Parent := Page.Surface; StaticText.Caption :='Inno Setup is already installed in'+' '+'"' + Location +'"'++' '+'on your system.'#13+ 'It is recommended that you uninstall the current version before continuing.'; StaticText.Left := 0; StaticText.Top := ScaleY(24); StaticText.TabOrder := 0; StaticText.AutoSize:=True; //Первый RadioButton RadioButton_1 := TRadioButton.Create(Page); RadioButton_1.Parent := Page.Surface; RadioButton_1.Caption := 'Uninstall '; RadioButton_1.Left := 0; RadioButton_1.Top := ScaleY(104); RadioButton_1.Width := ScaleX(233); RadioButton_1.Height := ScaleY(17); RadioButton_1.Checked := True; RadioButton_1.TabOrder := 1; RadioButton_1.TabStop := True; //Второй RadioButton RadioButton_2 := TRadioButton.Create(Page); RadioButton_2.Parent := Page.Surface; RadioButton_2.Caption := 'reinstall'; RadioButton_2.Left := 0; RadioButton_2.Top := ScaleY(144); RadioButton_2.Width := ScaleX(153); RadioButton_2.Height := ScaleY(17); RadioButton_2.TabOrder := 2; Page.OnNextButtonClick := @Page_NextButtonClick; Page.OnCancelButtonClick := @Page_CancelButtonClick; Result := Page.ID; end; procedure InitializeWizard(); begin if RegQueryStringValue(HKLM, 'Software\Microsoft\Windows\CurrentVersion\Uninstall\My Program_is1','UninstallString', Uninstall) then CheckInstalledPage(wpLicense); //Если параметр регистра присутствует,будет создана новая страница end; как сделать так чтобы после нажатия кнопкт uninstall закрывалась программа установки и удалялась программа уже установленная? |