As of October, 2016, Embarcadero is offering a free release
of Delphi (Delphi
10.1 Berlin Starter Edition ). There
are a few restrictions, but it is a welcome step toward making
more programmers aware of the joys of Delphi. They do say
"Offer may be withdrawn at any time", so don't delay if you want
to check it out. Please use the
link to let me know if the link stops working.
Support DFF - Shop
If you shop at Amazon anyway, consider using
this link. We receive a few cents from each purchase.
Support DFF - Donate
If you benefit from the website, in terms of
knowledge, entertainment value, or something otherwise useful,
consider making a donation via PayPal to help defray the
costs. (No PayPal account necessary to donate via credit
card.) Transaction is secure.
e-mail with your comments about this program (or anything else).
Sooner or later, every programmer wants to access drive and folder
information. I've had many questions about the techniques, so I
decided to post this demo program.
FindFirst and FindNext functions are used to access
folder information . Windows API functions GetLogicalDriveStrings
and GetDriveType give us access to drive
information. Their usage is straightforward once you know
which functions to use.
The program will
- List drive letters for specified drive types (I chose to make Fixed,
Network and CD-Rom types selectable),
- List a random file name from all files on all drives of selected types,
- List the first 100 file names matching a given file
mask. If you have Delphi version above
Standard, you have access to a MatchesMask function in
the Masks unit which provides a real mask matching
test. It ,might seem that FindFirst masking would
be useful but recursive searching of subdirectories makes its
use problematic. (We have to search with mask of *,* to ensure that all
folders are retuned). MatchesMask is a cleaner
solution. If you have Delphi Standard, there is commented code
to enable a file mask check which only searches for files
matching *.* or *.xxx extensions.
You can download the source for DriveDemo here.