Главная страница
    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.055 c
1-1100177535
andrey__
2004-11-11 15:52
2004.11.28
TServiceApplication - Pause, Continue, Stop


1-1100522855
PavelR
2004-11-15 15:47
2004.11.28
Английский формат даты в русский


3-1098811212
Sid
2004-10-26 21:20
2004.11.28
Обновление DBChart


1-1100618001
snake1977
2004-11-16 18:13
2004.11.28
Destructor для наследника TComboBox


1-1100249183
frEEstyler
2004-11-12 11:46
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
Английский Французский Немецкий Итальянский Португальский Русский Испанский