About GetDiskData
Language: Visual C++
Version: 1.1
Size: 280 Kb
(Statically linked)
Features
Remarks
How It Works
Bug Report
Request Source Code
Download
ScreenShots
Screen 1
Screen 2
Screen 3
Awards
|
|
|
Features
GetDiskData 1.1 is a sample application that shows how to retrieve the
main disk data:
Disk Type | Removable | Floppies, Zip drive, ... |
| Fixed Disk | Hard disks |
| CR-Rom | CD-Rom, DVD, CD Writer, ... |
| Network Disk | Any Remote Drive |
Volume Name | The label of the drive
Always 'Audio CD' for Music CD |
Serial Number | The Serial Number of the Volume
(Empty if Disk is not Ready for Use) |
Status | Ready | Means that drive is readable by the OS |
| Not Ready | Floppies, Zip Drives, Cd, ... not in Drive
Network Disk not Connected |
File System | FAT | Floppies, Zip Drives, Windows 95 HD, ... |
| FAT32 | New FAT for Windows 98 and NT |
| NTFS | High-Performance File System for NT |
| CDFS | CD-Rom File System |
Disk Capacity | Volume Capacity Available
in MB and GB Always 0 for Audio CD |
Free Space | Free Space on Drive Available
in MB and GB Always 0 for Audio CD |
Bytes/Sector | Number of Bytes per Disk Sector |
Sector/Cluster | Number of Sectors per Disk cluster |
Additonal features of GetDiskData 1.1, requested by Geoffroy de Wasseige, include
the resizing border for the application and the ability to restore window placement
to the place it was at the end of the previous session.
Remarks
1. Getting Data from the different drives of a machine could take a
long time according to the current status of the drives:
- it does not change a lot wheter or not the floppies are ready in floppy drive
- the same is True for CD-Rom
- however, it could take a while if network disks are unconnected before the
OS give up and considered them as not ready.
2. Some functions of Windows 95 are not able to handle disk larger than
2GB. Trying to get informations about large disk returns invalid data. In those
cases, the capacity and free space are set as '>= 2GB'.
How It Works
1. the function GetLogicalDriveStrings
is used to get the list of valid drives in the system. This
function fills the buffer passed as the first parameter with a Null character
as a separator between valid drives. The different drives are extracted from
the buffer and passed to the functions that actually performed the disk data
query.
2. the function GetDriveType returns
the type of drive. The first and only parameter of this function is the root
directory of the drive to check, as extracted from the buffer fills by the
function GetLogicalDriveStrings.
The different values are:
Value | Meaning |
DRIVE_UNKNOWN | The drive type cannot be determined |
DRIVE_NO_ROOT_DIR | The root directory does not exist |
DRIVE_REMOVABLE | The disk can be removed from the drive |
DRIVE_FIXED | The disk cannot be removed from the drive |
DRIVE_REMOTE | The drive is a remote (network) drive |
DRIVE_CDROM | The drive is a CD-ROM drive |
DRIVE_RAMDISK | The drive is a RAM disk |
3. the function GetVolumeInformation
returns different informations for the drive whose root directory is passed
as the first parameter.
- the volume name: this is the label of the drive as show in the 'Properties'
dialog of the drive (the one get with a right-click on the Drive Name in Explorer)
- the serial number of the drive
- the maximum length of a filename component, that is the maximum length
allowed between two backslashes in a file name. This is not shown in the sample.
- the file system flags: not handled nor showed
- the name of the file system: FAT, FAT32, NTFS, CDFS, ..
4. the function GetDiskFreeSpace does
the job of getting the total capacity and the free space of the drive whose
root directory is passed as the first parameter.
The different values retrieved are:
- the number of bytes per disk sector (BPS)
- the number of sectors per disk cluster (SPC)
- the total number of clusters on the disk (TNC)
- the number of free clusters on the disk (NFC)
The application makes the required computations to get the total capacity
and the free space of the disk:
Total Capacity = TNC * SPC * BPS (Result in bytes)
Free Space = NFC * SPC * BPS (Result in bytes)
to get the capacity or the free space in MB, divide by 1048576
to get the capacity or the free space in GB, divide again by 1024
5. the function GetVersionEx is used
to get the version of the Operating System. The application just checks the
member dwPlatformId of the OSVERSIONINFO strcture passed as the first parameter
of this function to verify wheter or not the OS is based on Windows NT. If this
is the case, the values returned by the function GetDiskFreeSpace are valid.
Otherwise, the application checks if the disk size is close to 2GB. If it
is the case, it just writes '>= 2GB'
Bug Report
Please report any bug to
Thierry.Marneffe@skynet.be
Request Source Code
Request Source Code
To get the free source code of this application, please report the request to
Thierry.Marneffe@skynet.be
|