.


:




:

































 

 

 

 


,




, , , .. . GetLogicalDrivers:

 

DWORD GetLogicalDrives(VOID)

 

32- , , : 0 - , 1 - B, 2 - .., 25 - Z. .

GetVolumeInformation, , , , , - DWORD:

 

BOOL GetVolumeInformation(

LPCTSTR lpRootPathName,

LPTSTR lpVolumeNameBuffer,

DWORD nVolumeNameSize,

LPDWORD lpVolumeSerialNumber,

LPDWORD lpMaximumComponentLength,

LPDWORD lpFileSystemFlags,

LPTSTR lpFileSystemNameBuffer,

DWORD nFileSystemNameSize

);

 

- lpRootPathName - , . NULL, .

. lpVolumeNameBuffer - , , - nVolumeNameSize - .

- lpVolumeSerialNumber .

- lpMaximumComponentLength , . FAT32 NTFS 255.

- lpFileSystemFlags , (. 23), .

. 23 lpFileSystemFlags

FS_CASE_SENSITIVE 0x00000001 , .
FS_CASE_IS_PRESERVED 0x00000002 , .
FS_UNICODE_STORED_ON_DISK 0x00000004 , Unicode.
FS_PERSISTENT_ACLS 0x00000008 , ACL ( NTFS).
FS_FILE_COMPRESSION 0x00000010 , .
FS_VOL_IS_COMPRESSED 0x00008000 , , , .

 

. lpFileSystemNameBuffer - , , - nFileSystemNameSize - .

(lpRootPathName, lpVolumeNameBuffer, lpVolumeSerialNumber lpFileSystemNameBuffer) , , GetMem.

GetVolumeInformation . FALSE, .

GetDriveType:

 

UINT GetDriveType(LPCTSTR lpRootPathName);

 

, . (. 24).

 

. 24

DRIVE_UNKNOWN   .
DRIVE_NO_ROOT_DIR   .
DRIVE_REMOVABLE   ( ).
DRIVE_FIXED   ( ).
DRIVE_REMOTE   ( ).
DRIVE_CDROM   CDROM.
DRIVE_RAMDISK   RAM-.

 

GetDiskFreeSpace :

 

BOOL GetDiskFreeSpace (

LPCTSTR lpRootPathName,

LPDWORD lpSectorsPerCluster,

LPDWORD lpBytesPerSector,

LPDWORD lpNumberOfFreeClusters,

LPDWORD lpTotalNumberOfClusters

);

 

- lpRootPathName - , . NULL, .

- lpSectorsPerCluster .

- lpBytesPerSector .

- lpNumberOfFreeClusters .

- lpTotalNumberOfClusters .

.1. , , . 6.

 

. 6

.2. TComboBox, OnCreate , :

 

procedure TForm1.FormCreate(Sender: TObject);

var mask,LogDrives,i: DWORD;

begin

LogDrives:=GetLogicalDrives;

mask:=1;

i:=0;

repeat

if (mask and LogDrives) <> 0

then ComboBox1.AddItem(chr(ord('A')+i)+':'+'\',nil);

i:=i+1;

mask:=mask shl 1;

until mask = 0;

end;

 

.3. ComboBox1 , StringGrid1.

GetVolumeInformation, GetDiskFreeSpace GetDriveType. , : , , . public TForm1 :

 

TForm1 = class(TForm)

//

 

private

{ Private declarations }

public

{ Public declarations }

SectorsPerClaster,BytesPerSector,FreeClasters,Clusters: DWORD;

Free,Busy,All: Int64;

MaxCompLength,FileSystemFlags: DWORD;

RootPathName,VolNameBuf,FileSystemNameBuf: PChar;

VolSerialNumber: PDWORD;

end;

 

OnCreate :

 

procedure TForm1.FormCreate(Sender: TObject);

var mask,LogDrives,i: DWORD;

begin

//

for i:=0 to high(InfoDrive) do

StringGrid1.Cells[0,i]:=InfoDrive[i]; //

//

GetMem(VolNameBuf,255);

GetMem(VolSerialNumber,255);

GetMem(FileSystemNameBuf,255);

end;

 

( GetMem) , .

OnChange Combobox1, :

 

procedure TForm1.ComboBox1Select(Sender: TObject);

var sDriveType: string;

BytesPerClaster: Int64;

begin

RootPathName:=PChar(ComboBox1.Items.Strings[ComboBox1.ItemIndex]);

if GetVolumeInformation(RootPathName,VolNameBuf,255,

VolSerialNumber,MaxCompLength,FileSystemFlags,

FileSystemNameBuf,255) then begin

StringGrid1.Cells[1,0]:=RootPathName;

StringGrid1.Cells[1,1]:=VolNameBuf;

StringGrid1.Cells[1,2]:=IntToHex(DWORD(VolSerialNumber^),8);

StringGrid1.Cells[1,3]:=IntToStr(MaxCompLength);

StringGrid1.Cells[1,4]:=IntToHex(FileSystemFlags,8);

StringGrid1.Cells[1,5]:=FileSystemNameBuf;

end

if GetDiskFreeSpace(RootPathName,SectorsPerClaster,

BytesPerSector,FreeClasters,Clusters) then begin

StringGrid1.Cells[1,6]:=IntToStr(SectorsPerClaster);

StringGrid1.Cells[1,7]:=IntToStr(BytesPerSector);

StringGrid1.Cells[1,8]:=IntToStr(FreeClasters);

StringGrid1.Cells[1,9]:=IntToStr(Clusters-FreeClasters);

StringGrid1.Cells[1,10]:=IntToStr(Clusters);

end

BytesPerClaster:=SectorsPerClaster*BytesPerSector;

All:=BytesPerClaster*Clusters;

Free:=BytesPerClaster*FreeClasters;

Busy:=All-Free;

StringGrid1.Cells[1,11]:=IntToStr(Free);

StringGrid1.Cells[1,12]:=IntToStr(Busy);

StringGrid1.Cells[1,13]:=IntToStr(All);

StringGrid1.Cells[1,14]:=TypeDrive[GetDriveType(RootPathName)];

 

end;

 

, :

 

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);

begin

FreeMem(VolNameBuf,255);

FreeMem(VolSerialNumber,255);

FreeMem(FileSystemNameBuf,255);

end;

 

 

1. FAT12.

2. FAT16.

3. FAT32.

4. NTFS.

5. CDFS.

6. C Win32 API Delphi , ;

7. C Win32 API Delphi , .

 

1. .. : . .: . 2006. -501 .

2. .., .. . . 2- . .: . 2008. 669 .

3. .. . : . 2007. -558 .

4. .. : . 2- . .: , 2007. 416 .

5. .. . . -. , 2006, 512





:


: 2016-11-24; !; : 464 |


:

:

, - , ; , - .
==> ...

1583 - | 1586 -


© 2015-2024 lektsii.org - -

: 0.041 .