[Code] 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; Text: TNewStaticText; 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 Page: TWizardPage; Text: TNewStaticText; Memo: TMemo; Path: string; FreeMB, TotalMB: Cardinal; drives: DWORD; i: integer; begin Text := TNewStaticText.Create(WizardForm); Text.Top := 102; Text.Width := 332; Text.Height := 14; Text.Caption := 'Список жестких дисков и свободного места'; Text.Parent := WizardForm.SelectDirPage; ListBox := TListBox.Create(WizardForm); ListBox.Top := 120; ListBox.Width := 332; ListBox.Height := ScaleY(90); ListBox.Parent := WizardForm.SelectDirPage; ListBox.OnClick := @ListBoxOnClick; ListBox.Font.Name := 'Courier New'; ListBox.Font.Size := 10; ListBox.Font.Style := [fsBold]; ListBox.Color := clBtnFace; 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(round(FreeMB / TotalMB * 100)) + '% ' + IntToStr(FreeMB) + ' MB'); 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; |