Possible Duplicate:
Get drive information (free space, etc.) for drives on Windows and populate a memo box
I am quite new to programing (especially Delphi), and have been unable to find any examples as to how to enumerate all the drives on a PC.
I really care about Hard Disks and CD-Rom drives but I have been unable to find anything useable.
Can anyone point me in the direction of a good working sample?
The simplest way is actually to use
GetDiskFreeSpaceExfrom thesysutils.pasfile.There are 2 parts to this example. the 1st is the important part using
GetDiskFreeSpaceEX.If you are going to request drives that you already know the drive letter for such as C: then that is all you need.
Usage would be something like:
Having said that if you want to find the drives as well you could use something like this:
Note the DriveType integer, should be one of the following:
(I have taken these straight out of
windows.pas)Now finally to answer your question (and this is very rough) the following would add information into a memo (called memo1) for all
FIXED HARD DRIVES:I did say it would be nasty! I have just run this up in the IDE and it works, I have done as MB but really you should convert to Double and choose your formatting if doing as MB to be more precise as the example I have create above will of course just round up.
Hope this is of some small assistance.