怎么获得指定磁盘分区的大小??
另外,磁盘分区的大小会不会有变化(除了重新分区的情况)〉?? 问题点数:20、回复次数:4Top
1 楼madyak(无天)回复于 2006-03-12 15:02:05 得分 0
Returns the size, in bytes, of a specified drive.
Unit
SysUtils
Category
file management routines
Delphi syntax:
function DiskSize(Drive: Byte): Int64;
C++ syntax:
extern PACKAGE __int64 __fastcall DiskSize(Byte Drive);
Description
DiskSize returns the size in bytes of the specified drive, where 0 = Current, 1 = A, 2 = B, etc. DiskSize returns -1 if the drive number is invalid.
Note: DiskSize is only available on Windows.
This example uses a form with a label on it. When the following code executes, it displays a message in the label indicating the number of KB free, and what percentage of the entire disk space that represents.
var
S: string;
AmtFree: Int64;
Total: Int64;
begin
AmtFree := DiskFree(0);
Total := DiskSize(0);
S := IntToStr(AmtFree div Total) + 'percent of the space on drive 0 is free: ' (AmtFree div 1024) + ' Kbytes free. ';
Label1.Caption := S;
end;
一般不重新分区,分区大小不会改变.Top
2 楼MarcusYin()回复于 2006-03-12 15:26:52 得分 0
非常感谢:madyak(无天)
另外还有一些疑问:这个函数是否适用于所有windows os(XP、2k);
scsi硬盘呢??fat32以及ntfs的都适用么??Top
3 楼madyak(无天)回复于 2006-03-12 17:20:19 得分 20
应该是没有问题的,不过我没测试过.Top
4 楼MarcusYin()回复于 2006-03-12 19:18:30 得分 0
好的,十分感谢Top




