Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works
Anything · Lazarus or Delphi
Random projectRandom project

Disk-Properties

To view Disk Properties on Delphi Programms.

View on GitHub

Member rating

No ratings yet.

Sign in to rate this project.

README

Disk-Properties:

Compiler      : 10 Seattle 10 1 Berlin 10 2 Tokyo 10 3 Rio
                     10 4 Sydney 11 Alexandria 12 Athens
Components : None
  :
 :
      :

To get disk properties in Delphi, you can use IOUtils's TDirectory.GetLogicalDrives for drive letters or the System.SysUtils.GetDiskFreeSpaceEx function to get details like total size and free space for a given drive letter. For detailed hardware information, you can access the Windows WMI (Windows Management Instrumentation) system, often with the help of the GLibWMI library or a component suite like TMiTeC's storage components.

</nr>

  • Get Drive Letters: Use System.IOUtils.TDirectory.GetLogicalDrives to retrieve a list of all available drive letters (e.g., "C:"). You can also use the older WinAPI GetLogicalDriveStrings for compatibility with older Delphi versions.
  • Get Free Space and Total Size: Once you have a drive letter, use System.SysUtils.GetDiskFreeSpaceEx(PChar(DriveLetter), UsedSpace, TotalSpace, @FreeSpace) to get the total, free, and used space in bytes for that drive.

Accessing Detailed Disk Properties with WMI

For more in-depth information such as disk type (HDD, SSD), serial number, or media type, you'll need to query the Windows WMI system.

  • Using Libraries: The GLibWMI Library is a component library that provides an easy way to access WMI information from Delphi. Embarcadero's blog also showcases the TMiTeC_DeviceMonitor component suite, which can list storage device properties.
  • WMI Information to Access: You can query for information like DriveType to distinguish between different drive types (e.g., local fixed, CD-ROM, removable). Details like SpindleSpeed for HDDs or media type for SSDs are available through WMI for more specific hardware properties.