NightW0lf
Код:
[Setup]
AppName=My Program
AppVerName=My Program version 1.5
DefaultDirName={pf}\My Program
[Files]
Source: Files\*; DestDir: {app}
[Сode]
const
NeedSize = 20; //Прописать, сколько мегабайт необходимо
DRIVE_UNKNOWN = 0;
DRIVE_NO_ROOT_DIR = 1;
DRIVE_REMOVEABLE = 2;
DRIVE_FIXED = 3;
DRIVE_REMOTE = 4;
DRIVE_CDROM = 5;
DRIVE_RAMDISK = 6;
var
ListBox: TListBox;
function GetLogicalDrives: DWORD;
external 'GetLogicalDrives@kernel32.dll stdcall';
function GetDriveType(nDrive: String): Longint;
external 'GetDriveTypeA@kernel32.dll stdcall';
procedure ListBoxOnClick(Sender: TObject);
var
NewLetter, OldString: String;
i: Integer;
begin
for i:= 0 to ListBox.Items.Count-1 do
begin
if ListBox.Selected[i] then
begin
NewLetter:= Copy(ListBox.Items[i], 0, 1);
OldString:= Copy(WizardForm.DirEdit.Text, 2, Length(WizardForm.DirEdit.Text));
WizardForm.DirEdit.Text:= NewLetter + OldString;
end;
end;
end;
procedure InitializeWizard();
var
Path: String;
FreeMB, TotalMB: Cardinal;
drives: DWORD;
i: integer;
begin
ListBox:= TListBox.Create(WizardForm);
ListBox.Top:= 120;
ListBox.Width:= 300;
ListBox.Height:= ScaleY(90);
ListBox.Parent:= WizardForm.SelectDirPage;
ListBox.OnClick:= @ListBoxOnClick;
drives:= GetLogicalDrives();
for i:= 0 to 31 do
begin
if (drives and (1 shl i)) > 0 then
begin
Path:= chr(ord('A')+i)+':';
if GetDriveType(Path) = DRIVE_FIXED then
begin
GetSpaceOnDisk(Path, True, FreeMB, TotalMB);
ListBox.Items.Add(Path + ' - Всего: ' + IntToStr(TotalMB) +
'Мб - Свободно: ' + IntToStr(FreeMB) + 'Мб');
end;
end;
end;
end;
function NextButtonClick(CurPageID: Integer): Boolean;
var
Path: String;
FreeMB, TotalMB: Cardinal;
begin
Result:= True;
if CurPageID = wpSelectDir then
begin
Path:= ExtractFileDrive(WizardForm.DirEdit.Text);
GetSpaceOnDisk(Path, True, FreeMB, TotalMB);
if FreeMB < NeedSize then
begin
MsgBox('Недостаточно места на диске!', mbInformation, MB_OK)
Result:= False;
end;
end;
end;
Код:
[Setup]
AppName=My Program
AppVerName=My Program version 1.5
DefaultDirName={pf}\My Program
[Files]
Source: Files\*; DestDir: {app}
[Сode]
const
NeedSize = 20; //Прописать, сколько мегабайт необходимо
DRIVE_UNKNOWN = 0;
DRIVE_NO_ROOT_DIR = 1;
DRIVE_REMOVEABLE = 2;
DRIVE_FIXED = 3;
DRIVE_REMOTE = 4;
DRIVE_CDROM = 5;
DRIVE_RAMDISK = 6;
var
ListBox: TListBox;
function GetLogicalDrives: DWORD;
external 'GetLogicalDrives@kernel32.dll stdcall';
function GetDriveType(nDrive: String): Longint;
external 'GetDriveTypeA@kernel32.dll stdcall';
procedure ListBoxOnClick(Sender: TObject);
var
NewLetter, OldString: String;
i: Integer;
begin
for i:= 0 to ListBox.Items.Count-1 do
begin
if ListBox.Selected[i] then
begin
NewLetter:= Copy(ListBox.Items[i], 0, 1);
OldString:= Copy(WizardForm.DirEdit.Text, 2, Length(WizardForm.DirEdit.Text));
WizardForm.DirEdit.Text:= NewLetter + OldString;
end;
end;
end;
procedure InitializeWizard();
var
Path: String;
FreeMB, TotalMB: Cardinal;
drives: DWORD;
i: integer;
begin
ListBox:= TListBox.Create(WizardForm);
ListBox.Top:= 120;
ListBox.Width:= 300;
ListBox.Height:= ScaleY(90);
ListBox.Parent:= WizardForm.SelectDirPage;
ListBox.OnClick:= @ListBoxOnClick;
drives:= GetLogicalDrives();
for i:= 0 to 31 do
begin
if (drives and (1 shl i)) > 0 then
begin
Path:= chr(ord('A')+i)+':';
if GetDriveType(Path) = DRIVE_FIXED then
begin
GetSpaceOnDisk(Path, True, FreeMB, TotalMB);
ListBox.Items.Add(Path + ' - Всего: ' + IntToStr(TotalMB) +
'Мб - Свободно: ' + IntToStr(FreeMB) + 'Мб');
end;
end;
end;
end;
function NextButtonClick(CurPageID: Integer): Boolean;
var
Path: String;
FreeMB, TotalMB: Cardinal;
begin
Result:= True;
if CurPageID = wpSelectDir then
begin
Path:= ExtractFileDrive(WizardForm.DirEdit.Text);
GetSpaceOnDisk(Path, True, FreeMB, TotalMB);
if FreeMB < NeedSize then
begin
MsgBox('Недостаточно места на диске!', mbInformation, MB_OK)
Result:= False;
end;
end;
end;