![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
GetDiskFreeSpace [D5, WinXP]
GanibalLector © (2004-10-15 20:51:00)Вот,играюсь с этой ф-цией в ОС XP.Все отлично было и тут решил посмотреть работу этой ф-ции на старых ОС(98).И,млин,вообще все не правильно(показывает правильно только неиспользуемое простр.диска С!!!Все отсальное неверно:общий размер,занятось...про остальные диски я вообще молчу).
Посмотрел на F1.Да,написано
Windows 95:
The GetDiskFreeSpace function returns incorrect values for volumes that are larger than 2 gigabytes. The function caps the values stored into *lpNumberOfFreeClusters and *lpTotalNumberOfClusters so as to never report volume sizes that are greater than 2 gigabytes.
Но у меня ж 98!!! Как так???
VMcL (2004-10-18 07:27:00) [1]См. GetDiskFreeSpaceEx()
GanibalLector (2004-10-18 01:55:00) [2]Что-то приходится самим с собой общаться.Жаль!
GanibalLector (2004-10-16 02:15:00) [3]Вот,собственно сабж(если кому в лом набирать)
const
DriveConst: array[1..26] of DWord =
($1, $2, $4, $8,
$10, $20, $40, $80,
$100, $200, $400, $800,
$1000, $2000, $4000, $8000,
$10000, $20000, $40000, $80000,
$100000, $200000, $400000, $800000,
$1000000, $2000000);
procedure TForm1.FormCreate(Sender: TObject);
var QQ,i:DWord;
begin
QQ:=GetLogicalDrives();
for i:=1 to 26 do
if (QQ and DriveConst[i])>0 then
Combobox1.Items.Add(chr($40+i)+':\');
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
var st:string;
VolumeName,FileSystemName : array [0..MAX_PATH-1] of Char;
VolumeSerialNumber,MaximumComponentLength,FileSystemFlags:DWord;
SectorsPerCluster,BytesPerSector,NumberOfFreeClusters,TotalNumberOfClusters:DWord;
begin
SetErrorMode(SEM_FAILCRITICALERRORS);
case GetDriveType(PChar(Combobox1.Text)) of
0: st:='Type :'+chr(09)+chr(09)+chr(09)+'Unknown'+#10#13;
1: st:='Type :'+chr(09)+chr(09)+chr(09)+'No_ROOT_DIR'+#10#13; // if RootPathName=nil
DRIVE_REMOVABLE: st:='Type :'+chr(09)+chr(09)+chr(09)+'Flopy'+#10#13;
DRIVE_FIXED: st:='Type :'+chr(09)+chr(09)+chr(09)+'Hard'+#10#13;
DRIVE_REMOTE: st:='Type :'+chr(09)+chr(09)+chr(09)+'Remote'+#10#13;
DRIVE_CDROM : st:='Type :'+chr(09)+chr(09)+chr(09)+'CD-ROM'+#10#13;
DRIVE_RAMDISK: st:='Type :'+chr(09)+chr(09)+chr(09)+'RAM-Disk'+#10#13;end;
st:=st+#10#13;
if GetVolumeInformation(Pchar(Combobox1.Text),VolumeName,MAX_PATH,
@VolumeSerialNumber,MaximumComponentLength,FileSystemFlags,FileSystemName,MAX_PATH)=true then
begin
st:=st+'Name :' +chr(09)+chr(09)+chr(09)+VolumeName+#10#13;
st:=st+'Serial :' +chr(09)+chr(09)+chr(09)+inttohex(VolumeSerialNumber,8)+#10#13;
st:=st+'Length :' +chr(09)+chr(09) +inttostr(MaximumComponentLength)+#10#13;
st:=st+'File system :'+chr(09)+chr(09) +FileSystemName+#10#13;
end
else st:=st+'Drive not ready'+#10#13; //ShowMessage(SysErrorMessage(GetLastError));
st:=st+#10#13;
if GetDiskFreeSpace(Pchar(Combobox1.Text),SectorsPerCluster,
BytesPerSector,NumberOfFreeClusters,TotalNumberOfClusters)=true then
begin
st:=st+'SectorsPerCluster :'+chr(09)+inttostr(SectorsPerCluster)+#10#13;
st:=st+'BytesPerSector : '+chr(09)+inttostr(BytesPerSector)+#10#13;
st:=st+#10#13;
st:=st+'FreeClusters : '+chr(09)+chr(09)+inttostr(NumberOfFreeClusters)+#10#13;
st:=st+'BusyClusters :'+chr(09)+chr(09)+inttostr(TotalNumberOfClusters-NumberOfFreeClusters)+#10#13;
st:=st+'TotalClusters :'+chr(09)+chr(09)+inttostr(TotalNumberOfClusters)+#10#13;
st:=st+#10#13;
st:=st+'FreeBytes :'+chr(09)+chr(09)+inttostr(NumberOfFreeClusters*(Int64(BytesPerSector*SectorsPerCluster)))+#10#13;
st:=st+'Busy :'+chr(09)+chr(09)+chr(09)+inttostr(TotalNumberOfClusters*(Int64(BytesPerSector*SectorsPerCluster))-
NumberOfFreeClusters*(Int64(BytesPerSector*SectorsPerCluster)))+#10#13;
st:=st+'TotalBytes :'+chr(09)+chr(09)+inttostr(TotalNumberOfClusters*(Int64(BytesPerSector*SectorsPerCluster)))+#10#13;
end;
messagedlg(Pchar(st),MtInformation,[MbOk],0);
end;