TDriveInfo

Version 1.1

Copyright © 1999 by Ingo Eckel
All rights reserved.

e-mail: mailto:Ingo.Eckel@t-online.de
web site: http://home.t-online.de/home/ingo.eckel/d4comp.htm

Overview:

TDriveInfo is a non-visible object used to centralize the management of the information about the installed drives. It has methods to store and retrieve the drive's valid status, its serialnumber, volumeID, imageindex, etc. and wether there is a disk inserted in the drive. The central instance of TDriveInfo is created at runtime and stored in the global variable DriveInfo. This instance will by automatically destroyed, when the application terminates. TDriveInfo is used by the components TDriveView, TDirView and TIEDriveComboBox.

 


Public properties:

Property Data[Drive : TDrive] : TDriveInfoRec; Default;
You can access the informations about a specific drive by using this default property. For example like this: DriveInfo['C']. The returned record TDriveInfoRec contains all informations about the specific drive. The drive will not by accessed by using this property. To update the informations stored in this property you should call the method ReadDriveStatus first.



Methods:

Function GetImageIndex(Drive : TDrive) : Integer
Returns the imageindex from the system imagelist for the drive.
 
Function GetDisplayName(Drive : TDrive) : String
Returns the displayname of the drive as used by the Explorer.
 
Function GetPrettyName(Drive : TDrive) : String
Returns the prettyfied displayname as used by TDriveView.
 
Function GetLongPrettyName(Drive : TDrive) : String
Returns the prettyfied displayname as used by TDriveView. On network drives the server name and -directories are also returned.
 
Function ReadDriveStatus(Drive : TDrive; Flags : Integer) : Boolean
Accesses the drive to retrieve specific informations about the given drive. The parameter Flags controls, wich informations should by retieved. Possible additional values are:

dsValid: Checks wether the drive is still valid. Network drives may by connected or disconnected at runtime.
dsImageIndex: Fetches the imageindex from the system imagelist for the drive.
dsSize: Fetches the size in bytes of the drive and the serialnumber of the drive.
dsDisplayName: Fetches the displayname of the drive as used by the explorer and updates the variable PrettyName.
dsAll: Same as dsImageIndex or dsSize or dsDisplayName.



Global functions and variables:

Function GetShellFileName (Const Name : String ) : String
Returns the displayname of the drive as used by the Explorer.
 
Function GetNetWorkName (Drive : Char) : String
Returns the UNC-name of the network drive.
 
DriveInfo : TDriveInfo
The central instance of TDriveInfo is stored in this global variable at runtime.
 

Data structures:

TDriveInfoRec = Record
This structure is used to store the information about a drive and could by accessed using the default property Data.

Init : Boolean; The drive has been accessed once.
Valid : Boolean; The drive is a valid drive.
DriveReady : Boolean; There is a disk inserted in the drive.
DriveType : Integer; DRIVE_REMOVABLE, DRIVE_FIXED, DRIVE_CDROM, DRIVE_RAMDISK or DRIVE_REMOTE.
DisplayName : String; Displayname of the drive as used by the Explorer.
Prettyname : String; Prettyfied displayname.
LongPrettyname : String; Prettyfied displayname, containing the server name and -directories on network drives.
DriveSerial : DWORD; Serial number of the drive.
Size : Int64; Size in bytes of the drive.
ImageIndex : Integer; Serial number of the drive.
FileSystemName : String; Filesystemname as returned by GetVolumeInformation
FileSystemFlags : DWORD; Filesystem flags as returned by GetVolumeInformation.
 

Limitations:

 

Currently none.

 


History:

 

V1.0: First published release.
V1.01: - Required compiler options inserted to avoid problems with global compiler settings different to the Delphi4 default settings.
- If the volumeID contains spaces, then the property PrettyName contains only the first part of the volumeID.
V1.1: New field LongPrettyName and method GetLongPrettyName.