Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Аватара для El Sanchez

Ветеран


Contributor


Сообщения: 1274
Благодарности: 1030

Профиль | Отправить PM | Цитировать


Johny777, держи, это писать в основном коде, код деинсталлятора не нужен.
читать дальше »

Код: Выделить весь код
#define MyAppName "test"

[Setup]
AppName={#MyAppName}
AppVerName={#MyAppName}
DefaultDirName={pf}\{#MyAppName}
UsePreviousAppDir=false
UsePreviousGroup=false
AlwaysShowComponentsList=true
FlatComponentsList=false
UsePreviousSetupType=false
UsePreviousTasks=false
UsePreviousUserInfo=false
DisableStartupPrompt=true
UninstallFilesDir={app}\uninstall
UninstallIconFile=icon.ico
AppMutex=testmutex
BitmapResource=unins:Cremator_poster.bmp

[Languages]
Name: ru; MessagesFile: compiler:Languages\russian.isl
Name: en; MessagesFile: compiler:Default.isl

[CustomMessages]
ru.Cremator=äâîðíèê Àëüÿíñà
en.Cremator=A Combine janitor of sorts

ru.remove=åìó ïîäìåñòè?
en.remove=should he sweep?

ru.Save=èëè ñíà÷àëà
en.Save=would you like to

ru.Save_Btn=ñîõðàíèøü ?
en.Save_Btn=save ?

en.rem=sweep
ru.rem=ñìåñòè

[Files]
Source: steam.cjstyles; DestDir: {#SetupSetting("UninstallFilesDir")}
Source: isskin.dll; DestDir: {#SetupSetting("UninstallFilesDir")}

[code]
procedure LoadSkin(lpszPath: String; lpszIniFileName: String); external 'LoadSkin@files:isskin.dll stdcall setuponly';
procedure UnloadSkin(); external 'UnloadSkin@files:isskin.dll stdcall setuponly';
procedure LoadSkinU(lpszPath: String; lpszIniFileName: String); external 'LoadSkin@{tmp}\isskin.dll stdcall delayload uninstallonly';
procedure UnloadSkinU(); external 'UnloadSkin@{tmp}\isskin.dll stdcall delayload uninstallonly';
function WINAPI_CreateMutex(lpMutexAttributes: Longint; bInitialOwner: BOOL; lpName: String): THandle; external 'CreateMutexA@kernel32.dll stdcall';
function ReleaseMutex(hMutex: THandle): BOOL; external 'ReleaseMutex@kernel32.dll stdcall';
function CloseHandle(hObject: THandle): BOOL; external 'CloseHandle@kernel32.dll stdcall';

var
    UninstallForm: TSetupForm;
    Save_Label: TLabel;
    hl2_Checkbox, ep1_Checkbox, ep2_Checkbox, portal_Checkbox: TCheckBox;
    ExitButton, UninstallButton: TButton;
    ResultCode: Integer;
    hMutex: THandle;

procedure InitializeWizard();
begin
    //create installer mutex
    hMutex := WINAPI_CreateMutex(0, False, ExpandConstant('{#SetupSetting("AppMutex")}'));
    
    //skin
    ExtractTemporaryFile('steam.cjstyles');
    LoadSkin(ExpandConstant('{tmp}\steam.cjstyles'), '');
end;

procedure Run_SAVE(Sender: TObject);
begin
    if ActiveLanguage = 'en' then Exec(ExpandConstant('{#SetupSetting("UninstallFilesDir")}\SAVE.exe'), '/LANG=English', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
    if ActiveLanguage = 'ru' then Exec(ExpandConstant('{#SetupSetting("UninstallFilesDir")}\SAVE.exe'), '/LANG=Russian', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
end;

function CreateUninstallForm: Integer;
begin
    UninstallForm := CreateCustomForm;
    with UninstallForm do
    begin
        BorderStyle := bsSingle;
        BorderIcons := [biSystemMenu,biMinimize];
        Position := poScreenCenter;
        Caption := 'Uninstall';
        ClientWidth := ScaleX(634);
        ClientHeight := ScaleY(586);

        //unins background bitmap image
        with TBitmapImage.Create(nil) do
        begin
            Parent := UninstallForm;
            Bitmap.LoadFromResourceName(HInstance, '_IS_UNINS');
            SetBounds(ScaleX(0), ScaleY(0), ScaleX(640), ScaleY(586));
            Hint := ExpandConstant('{cm:Cremator}');
            ShowHint := True;
            ParentShowHint := False;
        end;

        //should he sweep label
        Save_Label := TLabel.Create(nil);
        with Save_Label do
        begin
            Parent := UninstallForm;
            Left := ScaleX(400);
            Top := ScaleY(27);
            AutoSize := True;
            Caption := ExpandConstant('{cm:remove}');
            Font.Color := clWindowText;
            Font.Height := -16;
            Font.Name := 'Tahoma';
            ParentFont := False;
            Transparent := False;
            Font.Color := $48c1ca;
        end;

        //would you like to label
        with TLabel.Create(nil) do
        begin
            Parent := UninstallForm;
            SetBounds(ScaleX(460), ScaleY(50), ScaleX(270), ScaleY(16));
            AutoSize := False;
            Caption := ExpandConstant('{cm:Save}');
            Transparent := True;
            WordWrap := True;
            Font.Color := $48c1ca;
            Font.Size := 8;
        end;

        //uninstall button
        UninstallButton := TButton.Create(nil);
        with UninstallButton do
        begin
            Parent := UninstallForm;
            SetBounds(ScaleX(500), ScaleY(527), ScaleX(69), ScaleY(23));
            Cursor := crHand;
            Caption := SetupMessage(msgButtonYes);
            ModalResult := mrOk;
        end;

        //exit button
        ExitButton := TButton.Create(nil);
        with ExitButton do
        begin
            Parent := UninstallForm;
            SetBounds(UninstallButton.Left - UninstallButton.Width - ScaleX(16), UninstallButton.Top, UninstallButton.Width, UninstallButton.Height);
            Caption := SetupMessage(msgButtonNo);
            Cursor := crHand;
            ModalResult := mrCancel;
        end;

        //save button
        with TNewSpeedButton.Create(nil) do
        begin
            Parent := UninstallForm;
            if ActiveLanguage = 'ru' then SetBounds(Save_Label.Left + Save_Label.Width + ScaleX(20), Save_Label.Top + ScaleY(19), ScaleX(73), ScaleY(20));
            if ActiveLanguage = 'en' then SetBounds(Save_Label.Left + Save_Label.Width + ScaleX(20), Save_Label.Top + ScaleY(19), ScaleX(40), ScaleY(20));
            Caption := ExpandConstant('{cm:Save_Btn}');
            Enabled := FileExists(ExpandConstant('{#SetupSetting("UninstallFilesDir")}\SAVE.exe'));
            ThemeEnabled := False;
            Style := nsbButton;
            Font.Size := 8;
            Font.Color := $48c1ca;
            OnClick := @Run_SAVE;
        end;

        //hl2 checkbox
        hl2_Checkbox := TCheckBox.Create(nil);
        with hl2_Checkbox do
        begin
            Parent := UninstallForm;
            Caption := ExpandConstant('{cm:rem}');
            SetBounds(UninstallButton.Left, ScaleY(127), ScaleX(80), ScaleY(15));
            Checked := False;
            Enabled := FileExists(ExpandConstant('{app}\common\half-life 2\hl2.exe'));
        end;

        //ep1 checkbox
        ep1_Checkbox := TCheckBox.Create(nil);
        with ep1_Checkbox do
        begin
            Parent := UninstallForm;
            Caption := ExpandConstant('{cm:rem}');
            SetBounds(UninstallButton.Left, hl2_Checkbox.Top + ScaleY(116), ScaleX(70), ScaleY(15));
            Checked := False;
            Enabled := FileExists(ExpandConstant('{app}\common\half-life 2 episode one\hl2.exe'));
        end;

        //ep2 checkbox
        ep2_Checkbox := TCheckBox.Create(nil);
        with ep2_Checkbox do
        begin
            Parent := UninstallForm;
            Caption := ExpandConstant('{cm:rem}');
            SetBounds(UninstallButton.Left, ep1_Checkbox.Top + ScaleY(116), ScaleX(70), ScaleY(15));
            Checked := False;
            Enabled := FileExists(ExpandConstant('{app}\common\half-life 2 episode two\hl2.exe'));
        end;

        //portal checkbox
        portal_Checkbox := TCheckBox.Create(nil);
        with portal_Checkbox do
        begin
            Parent := UninstallForm;
            Caption := ExpandConstant('{cm:rem}');
            SetBounds(UninstallButton.Left, ep2_Checkbox.Top + ScaleY(116), ScaleX(70), ScaleY(15));
            Checked := False;
            Enabled := FileExists(ExpandConstant('{app}\common\portal\hl2.exe'));
        end;
        Result := ShowModal;
    end;
end;

function Unstall(): Boolean;
begin
    Result := False;

    //del hl2
    if hl2_Checkbox.Checked then
    begin
        DelTree(ExpandConstant('{app}\common\half-life 2'), True, True, True);
        DeleteFile(ExpandConstant('{app}\half-life 2 buka russian.gcf'));
        DeleteFile(ExpandConstant('{app}\half-life 2 2007 base content.gcf'));
        DeleteFile(ExpandConstant('{app}\half-life 2 content.gcf'));
        DeleteFile(ExpandConstant('{app}\half-life 2 game dialog.gcf'));
        DeleteFile(ExpandConstant('{userdesktop}\Half-Life 2.lnk'));

        SetIniString('Installed', 'hl2', '', ExpandConstant('{#SetupSetting("UninstallFilesDir")}\parameters.ini'));
        SetIniString('Installed', 'AuroraB', '',  ExpandConstant('{#SetupSetting("UninstallFilesDir")}\parameters.ini'));
        SetIniString('Installed', 'hl2_ru', '',  ExpandConstant('{#SetupSetting("UninstallFilesDir")}\parameters.ini'));
        SetIniString('Installed', 'hl2_ru_buka', '',  ExpandConstant('{#SetupSetting("UninstallFilesDir")}\parameters.ini'));
        SetIniString('Installed', 'hl2_en', '',  ExpandConstant('{#SetupSetting("UninstallFilesDir")}\parameters.ini'));
        SetIniString('Installed', 'hl2_ru_en', '', ExpandConstant('{#SetupSetting("UninstallFilesDir")}\parameters.ini'));
    end;

    //del ep1
    if ep1_Checkbox.Checked then
    begin
        DelTree(ExpandConstant('{app}\common\half-life 2 episode one'), True, True, True);
        DeleteFile(ExpandConstant('{app}\episode one 2007 content.gcf'));
        DeleteFile(ExpandConstant('{app}\half-life 2 episode one.gcf'));
        DeleteFile(ExpandConstant('{userdesktop}\Half-Life 2 Episode One.lnk'));

        SetIniString('Installed', 'ep1', '', ExpandConstant('{#SetupSetting("UninstallFilesDir")}\parameters.ini'));
        SetIniString('Installed', 'ep1_ru', '', ExpandConstant('{#SetupSetting("UninstallFilesDir")}\parameters.ini'));
        SetIniString('Installed', 'ep1_en', '',  ExpandConstant('{#SetupSetting("UninstallFilesDir")}\parameters.ini'));
        SetIniString('Installed', 'ep1_ru_en', '',  ExpandConstant('{#SetupSetting("UninstallFilesDir")}\parameters.ini'));
    end;

    //del ep2
    if ep2_Checkbox.Checked then
    begin
        DelTree(ExpandConstant('{app}\common\half-life 2 episode two'), True, True, True);
        DeleteFile(ExpandConstant('{app}\episode two content.gcf'));
        DeleteFile(ExpandConstant('{app}\episode two maps.gcf'));
        DeleteFile(ExpandConstant('{app}\episode two materials.gcf'));
        DeleteFile(ExpandConstant('{app}\half-life 2 episode two english.gcf'));
        DeleteFile(ExpandConstant('{app}\half-life 2 episode two russian.gcf'));
        DeleteFile(ExpandConstant('{userdesktop}\Half-Life 2 Episode Two.lnk'));

        SetIniString('Installed', 'ep2', '', ExpandConstant('{#SetupSetting("UninstallFilesDir")}\parameters.ini'));
        SetIniString('Installed', 'ep2_ru', '',  ExpandConstant('{#SetupSetting("UninstallFilesDir")}\parameters.ini'));
        SetIniString('Installed', 'ep2_en', '',  ExpandConstant('{#SetupSetting("UninstallFilesDir")}\parameters.ini'));
        SetIniString('Installed', 'ep2_ru_en', '',  ExpandConstant('{#SetupSetting("UninstallFilesDir")}\parameters.ini'));
    end;

    //del portal
    if portal_Checkbox.Checked then
    begin
        DelTree(ExpandConstant('{app}\common\portal'), True, True, True);
        DeleteFile(ExpandConstant('{app}\portal content.gcf'));
        DeleteFile(ExpandConstant('{app}\portal english.gcf'));
        DeleteFile(ExpandConstant('{app}\portal russian.gcf'));
        DeleteFile(ExpandConstant('{userdesktop}\Portal.lnk'));

        SetIniString('Installed', 'portal', '', ExpandConstant('{#SetupSetting("UninstallFilesDir")}\parameters.ini'));
        SetIniString('Installed', 'portal_ru', '', ExpandConstant('{#SetupSetting("UninstallFilesDir")}\parameters.ini'));
        SetIniString('Installed', 'portal_en', '', ExpandConstant('{#SetupSetting("UninstallFilesDir")}\parameters.ini'));
        SetIniString('Installed', 'portal_ru_en', '', ExpandConstant('{#SetupSetting("UninstallFilesDir")}\parameters.ini'));
    end;

    //del episodes gcf
    if not FileExists(ExpandConstant('{app}\common\half-life 2 episode one\hl2.exe')) and
    not FileExists(ExpandConstant('{app}\common\half-life 2 episode two\hl2.exe')) then
    begin
        DeleteFile(ExpandConstant('{app}\episode 1 shared.gcf'));
        DeleteFile(ExpandConstant('{app}\episodic 2007 shared.gcf'));
        DeleteFile(ExpandConstant('{app}\half-life 2 episode one russian.gcf'));
    end;

    //del russian hl2 gcf
    if not FileExists(ExpandConstant('{app}\common\half-life 2\hl2.exe')) and
    not FileExists(ExpandConstant('{app}\common\half-life 2 episode one\hl2.exe')) and
    not FileExists(ExpandConstant('{app}\common\half-life 2 episode two\hl2.exe')) then
        DeleteFile(ExpandConstant('{app}\half-life 2_russian.gcf'));

    //full uninstall
    if not FileExists(ExpandConstant('{app}\common\half-life 2\hl2.exe')) and
    not FileExists(ExpandConstant('{app}\common\half-life 2 episode one\hl2.exe')) and
    not FileExists(ExpandConstant('{app}\common\half-life 2 episode two\hl2.exe')) and
    not FileExists(ExpandConstant('{app}\common\portal\hl2.exe')) then
    begin
        MsgBox(FmtMessage(SetupMessage(msgUninstalledAll), ['{#MyAppName}']), mbInformation, MB_OK);
        Result := True;
    end;

    //release deinstall mutex
    ReleaseMutex(hMutex);
    CloseHandle(hMutex);

    UninstallForm.Close;
end;

function InitializeUninstall(): Boolean;
begin
    Result := False;

    //skin
    if FileCopy(ExpandConstant('{#SetupSetting("UninstallFilesDir")}\steam.cjstyles'), ExpandConstant('{tmp}\steam.cjstyles'), True) and
    FileCopy(ExpandConstant('{#SetupSetting("UninstallFilesDir")}\isskin.dll'), ExpandConstant('{tmp}\isskin.dll'), True) then
        LoadSkinU(ExpandConstant('{tmp}\steam.cjstyles'), '');

    if not UninstallSilent then
    begin
        Exec(ExpandConstant('{uninstallexe}'), '/VERYSILENT', '', SW_SHOW, ewNoWait, ResultCode);
        Exit;
    end;

    //check install mutex
    if CheckForMutexes(ExpandConstant('{#SetupSetting("AppMutex")}')) then
    begin
        MsgBox(FmtMessage(SetupMessage(msgUninstallAppRunningError), ['{#MyAppName}']), mbError, MB_OK);
        Exit;
    end;

    //create deinstall mutex
    hMutex := WINAPI_CreateMutex(0, False, ExpandConstant('{#SetupSetting("AppMutex")}'));

    if CreateUninstallForm = mrOk then Result := Unstall();
    UninstallForm.Free;
end;

procedure DeinitializeUninstall();
begin
    if FileExists(ExpandConstant('{tmp}\steam.cjstyles')) and FileExists(ExpandConstant('{tmp}\isskin.dll')) then UnloadSkinU();
end;

procedure DeinitializeSetup;
begin
    UnloadSkin();
    ReleaseMutex(hMutex);
    CloseHandle(hMutex);
end;
Это сообщение посчитали полезным следующие участники:

Отправлено: 15:07, 23-06-2012 | #305