perf92
Junior Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору var n: Integer; FreeMB, TotalMB: Cardinal; VolumeName, FileSystemName: String; VolumeSerialNo, MaxComponentLength, FileSystemFlags: Longint; ListBox: TListBox; StartMenuTreeView: TStartMenuFolderTreeView; const oneMB= 1024*1024; function GetLogicalDrives: DWord; external 'GetLogicalDrives@kernel32.dll stdcall'; function GetDriveType(nDrive: String): Longint; external 'GetDriveTypeA@kernel32.dll stdcall'; function GetVolumeInformation(PathName,VolumeName: PChar; VolumeNameSize,VolumeSerialNumber,MaxComponentLength,FileSystemFlags: Longint; FileSystemName: PChar; FileSystemNameSize: Longint): Longint; external 'GetVolumeInformationA@kernel32.dll stdcall'; function MessageBox(hWnd: Integer; lpText, lpCaption: String; uType: Cardinal): Integer; external 'MessageBoxA@user32.dll stdcall'; Function ByteOrTB(Bytes: Extended; noMB: Boolean): String; { Ïåðåâîä ÷èñëà â çíà÷åíèå áò/Êá/Ìá/Ãá/Òá (äî 3õ çíàêîâ ïîñëå çàïÿòîé)} Begin if not noMB then Result:= FloatToStr(Int(Bytes)) +' Ìá' else if Bytes < 1024 then Result:= FloatToStr(Int(Bytes)) +' Áò' else if Bytes/1024 < 1024 then Result:= FloatToStr(round((Bytes/1024)*10)/10) +' Êá' else If Bytes/oneMB < 1024 then Result:= FloatToStr(round(Bytes/oneMB*100)/100) +' Ìá' else If Bytes/oneMB/1000 < 1024 then Result:= FloatToStr(round(Bytes/oneMB/1024*1000)/1000) +' Ãá' else Result:= FloatToStr(round(Bytes/oneMB/oneMB*1000)/1000) +' Òá' StringChange(Result, ',', '.') End; Function DelSP(String: String): String; { Óäàëåíèå íà÷àëüíûõ, êîíå÷íûõ è ïîâòîðíûõ ïðîáåëîâ } Begin while (Pos(' ', String) > 0) do Delete(String, Pos(' ', String), 1); Result:= Trim(String); End; Function CutString(String: String; MaxLength: Longint): String; { Îáðåçàòü ñòðîêó äî çàäàííîãî êîë-âà ñèìâîëîâ} Begin if Length(String) > MaxLength then Result:= Copy(String, 1, 6) +'...'+ Copy(String, Length(String) - MaxLength +9, MaxLength) else Result:= String; End; Procedure GetDiskInfo(Disk: String); Begin FileSystemName:= StringOfChar(' ', 32); VolumeName:= StringOfChar(' ', 256); GetVolumeInformation(Disk, VolumeName, 255, VolumeSerialNo, MaxComponentLength, FileSystemFlags, FileSystemName, 31); FileSystemName:= DelSp(FileSystemName); VolumeName:= DelSp(VolumeName); if VolumeName='' then VolumeName:='áåç ìåòêè'; End; Procedure ListBoxRefresh; var FreeB, TotalB: Cardinal; Path, String: string; Begin ListBox.Items.Clear for n:= 1 to 31 do // äèñê 'À' ïðîïóñòèòü if (GetLogicalDrives and (1 shl n)) > 0 then if (GetDriveType(Chr(ord('A') + n) +':\') = 2) or (GetDriveType(Chr(ord('A') + n) +':\') = 3) then if GetSpaceOnDisk(Chr(ord('A') + n) +':\', True, FreeMB, TotalMB) then ListBox.Items.Add(Chr(ord('A') + n) +':'); for n:= 0 to ListBox.Items.Count -1 do begin Path:= Copy(ListBox.Items[n],1,2) +'\' { åñëè â íàêîïèòåëå íåò äèñêà, ïðîïóñòèòü îáíîâëåíèå } if GetSpaceOnDisk(Path, False, FreeB, TotalB) and GetSpaceOnDisk(Path, True, FreeMB, TotalMB) then begin GetDiskInfo(Path); if FreeB >= $7FFFFFFF then String:= PadL(ByteOrTB(FreeMB*oneMB, true),10) else String:= PadL(ByteOrTB(FreeB, true),10); if TotalB >= $7FFFFFFF then begin TotalB:= TotalMB; FreeB:= FreeMB; String:= PadL(ByteOrTB(TotalMB*oneMB, true),11) +' âñåãî| '+ String end else String:= PadL(ByteOrTB(TotalB, true),11) +' âñåãî| '+ String; ListBox.Items[n]:= Copy(Path,1,2) + String + PadL(FloatToStr(round(FreeB/TotalB*100)),3)+ '% ñâîá|'+ PadL(FileSystemName,5)+ '| '+ CutString(VolumeName,9); end; end; End; Procedure ObjectOnClick(Sender: TObject); Begin Case TObject(Sender) of ListBox: for n:= 0 to ListBox.Items.Count-1 do if ListBox.Selected[n] then WizardForm.DirEdit.Text:= Copy(ListBox.Items[n],1,1) +Copy(WizardForm.DirEdit.Text, 2, Length(WizardForm.DirEdit.Text)) StartMenuTreeView: if StartMenuTreeView.Directory <> '' then WizardForm.GroupEdit.Text:= StartMenuTreeView.Directory else WizardForm.GroupEdit.Text:= '{#SetupSetting("DefaultGroupName")}' WizardForm.NoIconsCheck: begin WizardForm.GroupEdit.Enabled:= not(WizardForm.GroupEdit.Enabled); StartMenuTreeView.Enabled:= WizardForm.GroupEdit.Enabled; WizardForm.GroupBrowseButton.Enabled:= WizardForm.GroupEdit.Enabled end; end; End; Function NextButtonClick(CurPageID: Integer): Boolean; Begin Result:= True if (CurPageID = wpSelectDir) and (Pos(Uppercase(ExpandConstant('{win}')), Uppercase(ExpandConstant('{app}'))) > 0) then Result:= MessageBox(StrToInt(ExpandConstant('{wizardhwnd}')), ExpandConstant('{cm:SysDirSelect}'), 'Óñòàíîâêà â ñèñòåìíóþ ïàïêó', MB_YESNO or $30) = idYes; End; Procedure CurPageChanged(CurPageID: Integer); Begin if CurPageID = wpSelectDir then ListBoxRefresh End; Procedure InitializeWizard; Begin ListBox:= TListBox.Create(WizardForm) ListBox.SetBounds(WizardForm.DirEdit.Left, WizardForm.DirEdit.Top + WizardForm.DirEdit.Height + 8, WizardForm.DirBrowseButton.Left + WizardForm.DirBrowseButton.Width - WizardForm.DirEdit.Left, WizardForm.DiskSpaceLabel.Top - (WizardForm.DirEdit.Top + WizardForm.DirEdit.Height + 12)) ListBox.Font.Size:= 9 ListBox.Font.Style:= [fsBold] ListBox.Font.Name:= 'Courier New'; ListBox.OnClick:= @ObjectOnClick; ListBox.Parent:= WizardForm.SelectDirPage; WizardForm.NoIconsCheck.SetBounds(WizardForm.DiskSpaceLabel.Left + 96, WizardForm.DiskSpaceLabel.Top + 1, WizardForm.NoIconsCheck.Width, WizardForm.NoIconsCheck.Height) WizardForm.NoIconsCheck.OnClick:= @ObjectOnClick WizardForm.NoIconsCheck.Parent:= WizardForm.SelectProgramGroupPage WizardForm.NoIconsCheck.Show StartMenuTreeView:= TStartMenuFolderTreeView.Create(WizardForm) StartMenuTreeView.SetPaths(ExpandConstant('{userprograms}'), ExpandConstant('{commonprograms}'), ExpandConstant('{userstartup}'), ExpandConstant('{commonstartup}')); StartMenuTreeView.SetBounds(ListBox.Left, ListBox.Top, ListBox.Width, ListBox.Height) StartMenuTreeView.Parent:= WizardForm.SelectProgramGroupPage StartMenuTreeView.Cursor:= crHand StartMenuTreeView.OnChange:=@ObjectOnClick End; | Всего записей: 46 | Зарегистр. 01-05-2009 | Отправлено: 20:29 02-05-2009 | Исправлено: perf92, 21:25 02-05-2009 |
|