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

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

Ветеран


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

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


Цитата Ivan_009:
Как прописать только сколько Требуется места для установки и Занимаемое место после установки.
Зарание спасибо... (Если можно дайте пожалуйста пример) »
читать дальше »

Выдернул из скрипта. Думаю разберетесь)
Код: Выделить весь код
[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application
OutputDir=...
DisableWelcomePage=yes


[Files]
Source: C:\Windows\Fonts\*; DestDir: {app}; Flags: external overwritereadonly ignoreversion; ExternalSize: 50000000000;


[CustomMessages]
MESSAGE_23=Требуется места на диске:
MESSAGE_24=Доступно места на диске:
MESSAGE_25=Файловая система:
MESSAGE_26=МБ
MESSAGE_27=ГБ
MESSAGE_28=ТБ


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


const
    MAX_PATH                 = 260;
    TARGET_FILE_SYSTEM       = 'NTFS';


function GetVolumeInformation(lpRootPathName, lpVolumeNameBuffer: String; nVolumeNameSize, lpVolumeSerialNumber: DWORD;
  var lpMaximumComponentLength, lpFileSystemFlags: DWORD; lpFileSystemNameBuffer: String; nFileSystemNameSize: DWORD): BOOL;
    external 'GetVolumeInformation{#A}@kernel32.dll stdcall';


var
    MinorInfoLabels, MainInfoLabels: array of TNewStaticText;
    


function GetFreeDriveSpace(const UndefInstallPath: String): Cardinal;
var
    TotalMB: Cardinal;
begin
    GetSpaceOnDisk(ExtractFileDrive(UndefInstallPath), True, Result, TotalMB);
end;


function GetFloatFromText(const UndefText: String): String;
var
    i, Len: Integer;
begin
    Len := Length(UndefText);

    for i := 1 to Len do
    case UndefText[i] of
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': Result := Result + UndefText[i];
        ',': Result := Result + '.';
    end;
end;


function NumToStr(const Float: Extended): String;
var
    Len: Integer;
begin
    Result := Format('%.2n', [Float]);
    StringChange(Result, ',', '.');
    Len := Length(Result);

    while ((Result[Len] = '0') or (Result[Len] = '.')) and (Pos('.', Result) > 0) do
        begin
            Delete(Result, Len, 1);
            Len := Length(Result);
        end;
end;


function UnitDriveSpace(const Float: Extended): String;
begin
    if (Float < 1024) then Result := NumToStr(Float) + #32 + CustomMessage('MESSAGE_26')
    else if (Float/1024 < 1024) then Result := NumToStr(Float/1024) + #32 + CustomMessage('MESSAGE_27')
    else Result := NumToStr(Float/(1024*1024)) + #32 + CustomMessage('MESSAGE_28');
end;


function CompareDriveRequirements(const FromText: String; const Input: String): Boolean;
var
    Len: Integer;
    CompareSpace, CompareFileSystem: Boolean;
    UndefNeedSize, UndefFreeSize: Extended;
    VolumeName, FileSystemName, DriveLetter: String;
    ComponentLength, SerialNumber, FileSystemFlags: DWORD;
begin
    Len := GetArrayLength(MainInfoLabels) - 1;

    UndefNeedSize := StrToFloat(GetFloatFromText(FromText));
    UndefFreeSize := Extended(GetFreeDriveSpace(Input));
    VolumeName := StringOfChar(#32, MAX_PATH);
    FileSystemName := StringOfChar(#32, MAX_PATH);
    DriveLetter := AddBackslash(ExtractFileDrive(Input));

    GetVolumeInformation(DriveLetter, VolumeName, MAX_PATH, SerialNumber, ComponentLength, FileSystemFlags, FileSystemName, MAX_PATH);

    MainInfoLabels[0].Caption := UnitDriveSpace(UndefNeedSize);
    MainInfoLabels[1].Caption := UnitDriveSpace(UndefFreeSize);
    MainInfoLabels[Len].Caption := Trim(FileSystemName);

    CompareSpace := (UndefFreeSize > UndefNeedSize);

    case CompareSpace of
        True: MainInfoLabels[1].Font.Color := clBlack;
        False: MainInfoLabels[1].Font.Color := clRed;
    end;

    CompareFileSystem := (Trim(FileSystemName) >= TARGET_FILE_SYSTEM);

    case CompareFileSystem of
        True: MainInfoLabels[Len].Font.Color := clBlack;
        False: MainInfoLabels[Len].Font.Color := clRed;
    end;

    Result := (CompareSpace and CompareFileSystem);
    WizardForm.NextButton.Enabled := Result;
end;


procedure WizardEditsOnChange(Sender: TObject);
begin
    case TEdit(Sender) of
        WizardForm.DirEdit: CompareDriveRequirements(WizardForm.DiskSpaceLabel.Caption, WizardDirValue());
    end;
end;


procedure CreateCustomControls();
var
    i, Len: Integer;
    InfoBox: TNewGroupBox;
begin
    with WizardForm do
    begin
        InfoBox := TNewGroupBox.Create(SelectDirPage);
        with InfoBox do
        begin
            Parent := SelectDirPage;
            SetBounds(ScaleX(12), ScaleY(120), ScaleX(450), ScaleY(86));

            SetArrayLength(MinorInfoLabels, 3);
            Len := GetArrayLength(MinorInfoLabels) - 1;

            for i := 0 to Len do
            begin
                MinorInfoLabels[i] := TNewStaticText.Create(InfoBox);
                with MinorInfoLabels[i] do
                begin
                    Parent := InfoBox;
                    SetBounds(ScaleX(16), ScaleY(13 + i*23), ScaleX(138), ScaleY(14));
                    AutoSize := False;

                    case i of
                        0: Caption := CustomMessage('MESSAGE_23');
                        1: Caption := CustomMessage('MESSAGE_24');
                        Len: Caption := CustomMessage('MESSAGE_25');
                    end;
                end;
            end;

            SetArrayLength(MainInfoLabels, 3);
            Len := GetArrayLength(MainInfoLabels) - 1;

            for i := 0 to Len do
            begin
                MainInfoLabels[i] := TNewStaticText.Create(InfoBox);
                with MainInfoLabels[i] do
                begin
                    Parent := InfoBox;
                    SetBounds(ScaleX(165), ScaleY(13 + i*23), ScaleX(268), ScaleY(14));
                    AutoSize := False;
                end;
            end;
        end;
    end;
end;


procedure ModifyWizardForm();
begin
    with WizardForm do
    begin
        ClientWidth := ScaleX(498);
        ClientHeight := ScaleY(354);
        BorderStyle := bsDialog;
        Position := poScreenCenter;

        OuterNotebook.SetBounds(ScaleX(0), ScaleY(0), ScaleX(498), ScaleY(302));
        InnerNotebook.SetBounds(ScaleX(12), ScaleY(62), ScaleX(474), ScaleY(238));
        MainPanel.SetBounds(ScaleX(0), ScaleY(0), ScaleX(498), ScaleY(60));
        Bevel1.SetBounds(ScaleX(0), ScaleY(60), ScaleX(498), ScaleY(3));
        BeveledLabel.Top := ScaleY(294);
        BackButton.SetBounds(ScaleX(252), ScaleY(318), ScaleX(75), ScaleY(23));
        NextButton.SetBounds(ScaleX(327), ScaleY(318), ScaleX(75), ScaleY(23));
        CancelButton.SetBounds(ScaleX(412), ScaleY(318), ScaleX(75), ScaleY(23));
        PageNameLabel.SetBounds(ScaleX(16), ScaleY(10), ScaleX(324), ScaleY(14));
        PageDescriptionLabel.SetBounds(ScaleX(24), ScaleY(26), ScaleX(316), ScaleY(28));
        SelectDirLabel.SetBounds(ScaleX(68), ScaleY(9), ScaleX(262), ScaleY(14));
        SelectDirBitmapImage.Left := ScaleX(12);
        SelectDirBrowseLabel.Left := ScaleX(12);

        with DirEdit do
        begin
            Left := ScaleX(12);
            Width := ScaleX(370);
            OnChange := @WizardEditsOnChange;
        end;
        
        DirBrowseButton.Left := ScaleX(387);
        DiskSpaceLabel.Hide;
    end;
end;


procedure InitializeWizard();
begin
    ModifyWizardForm();
    CreateCustomControls();
end;


procedure CurPageChanged(CurPageID: Integer);
begin
    case CurPageID of
        wpSelectDir: WizardEditsOnChange(WizardForm.DirEdit);
    end;
end;
Это сообщение посчитали полезным следующие участники:

Отправлено: 21:08, 05-02-2014 | #2140