Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > C/C++: Системное программирование и WinAPI > Перевод GetDiskFreeSpace в читабельный вид


Автор: Johen 28.12.2004, 12:30
Привет всем! И с Наступающим!

Вопрос такой: функция GetDiskFreeSpace вернула некоторые данные. Как эти данные перевести в читабельный вид(т.е. в char или в int)?

Автор: _hunter 28.12.2004, 12:51
а в чем проблема?
WORD в строку перевести -- IntToStr ( Builder )
или itoa ( VC )
рзмер:
NumberOfFreeClusters*SectorsPerCluster*BytesPerSector

Автор: Mad 28.12.2004, 12:54
Код

DWORD SectorsPerCluster;
DWORD BytesPerSector;
DWORD NumberOfFreeClusters;
DWORD TotalNumberOfClusters;

GetDiskFreeSpace(RootPathName, &SectorsPerCluster, &BytesPerSector, &NumberOfFreeClusters, &TotalNumberOfClusters);

unsigned long FreeBytes = NumberOfFreeClusters*BytesPerSector*SectorsPerCluster;


Только надо помнить, что результат такого перемножения может быть и 64битным smile

Автор: _hunter 28.12.2004, 13:01
не должон:
Цитата
The GetDiskFreeSpace function cannot report volume sizes that are greater than 2 gigabytes (GB).

Автор: Mad 28.12.2004, 13:08
Цитата(MSDN)
Windows 95 OSR2 and later:  The GetDiskFreeSpaceEx function is available beginning with Windows 95 OEM Service Release 2 (OSR2), and you should use it whenever possible. The GetDiskFreeSpaceEx function returns correct values for all volumes, including those that are larger than 2 GB.



Windows Me/98/95:  For volumes that are larger than 2 GB, the GetDiskFreeSpace function may return misleading values. The function caps the values stored into *lpNumberOfFreeClusters and *lpTotalNumberOfClusters so as to never report volume sizes that are greater than 2 GB. On volumes that are smaller than 2 GB with an actual sectors per cluster greater than 64, *lpSectorsPerCluster will be capped at 64 and the values stored into *lpSectorsPerCluster, *lpNumberOfFreeClusters, and *lpTotalNumberOfClusters will be incorrect. That is because the operating system adjusts the values so that computations with them yield the correct volume size with the capped *lpSectorsPerCluster.




Windows Me/98/95:  GetDiskFreeSpaceW is supported by the Microsoft Layer for Unicode. To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems.


Судя по этому куску - может, правда изначаль (в самих переменных) будут некоректные данные smile

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)