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

getdiskdata Download
  Features

GetDiskData 1.1 is a sample application that shows how to retrieve the main disk data:

Disk TypeRemovableFloppies, Zip drive, ...
 Fixed DiskHard disks
 CR-RomCD-Rom, DVD, CD Writer, ...
 Network DiskAny Remote Drive
Volume NameThe label of the drive
Always 'Audio CD' for Music CD
Serial NumberThe Serial Number of the Volume
    (Empty if Disk is not Ready for Use)
StatusReadyMeans that drive is readable by the OS
 Not ReadyFloppies, Zip Drives, Cd, ... not in Drive
Network Disk not Connected
File SystemFATFloppies, Zip Drives, Windows 95 HD, ...
 FAT32New FAT for Windows 98 and NT
 NTFSHigh-Performance File System for NT
 CDFSCD-Rom File System
Disk CapacityVolume Capacity Available in MB and GB
Always 0 for Audio CD
Free SpaceFree Space on Drive Available in MB and GB
Always 0 for Audio CD
Bytes/SectorNumber of Bytes per Disk Sector
Sector/ClusterNumber 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:
ValueMeaning
DRIVE_UNKNOWNThe drive type cannot be determined
DRIVE_NO_ROOT_DIRThe root directory does not exist
DRIVE_REMOVABLEThe disk can be removed from the drive
DRIVE_FIXEDThe disk cannot be removed from the drive
DRIVE_REMOTEThe drive is a remote (network) drive
DRIVE_CDROMThe drive is a CD-ROM drive
DRIVE_RAMDISKThe 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




  • The application GetDiskData 1.1 is written according to the standard techniques and recommandations for the development of applications for Windows. The application has been tested extensively to verify its correct behaviour and memory management and to determine its effectiveness on different computers including network-linked computers.

    The author makes no warranty of any kind, expressed or implied, with regard to this application and not be liable in any event for any direct, incidental or consequential damages, loss of profit or data, interruption of businees arising out of the performance or use of this program, even if the author has been advised to the possibility of such damages.

    Donwload and Use of this software indicates your acceptance of these terms and conditions.

    Download