Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "WinAPI";
Текущий архив: 2004.11.28;
Скачать: [xml.tar.bz2];

Вниз

GetDiskFreeSpace   Найти похожие ветки 

 
GanibalLector ©   (2004-10-15 20:51) [0]

Вот,играюсь с этой ф-цией в ОС 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!!! Как так???


 
GanibalLector ©   (2004-10-16 02:15) [1]

Вот,собственно сабж(если кому в лом набирать)

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;


 
GanibalLector ©   (2004-10-18 01:55) [2]

Что-то приходится самим с собой общаться.Жаль!


 
VMcL ©   (2004-10-18 07:27) [3]

См. GetDiskFreeSpaceEx()



Страницы: 1 вся ветка

Форум: "WinAPI";
Текущий архив: 2004.11.28;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.46 MB
Время: 0.07 c
6-1095942371
Russko
2004-09-23 16:26
2004.11.28
Работа в чате


1-1100624643
TSoftman
2004-11-16 20:04
2004.11.28
Копирование файлов с визуализацией


1-1100170567
Fynjy1984
2004-11-11 13:56
2004.11.28
Графики


8-1093899182
AlexZ
2004-08-31 00:53
2004.11.28
Где бы почитать про GDI, кроме Win32P sR


1-1100533878
Chery
2004-11-15 18:51
2004.11.28
Имя и метка системного диска





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский