eNarc
asked on
how to get the list of active hard drives
Hi, how do I get the list of active Hard Drives that are connected?
and list them in a combobox drop down as C: H: etc
and list them in a combobox drop down as C: H: etc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try this
var
Drive : byte;
DriveName: string;
mybutton: TsBitBtn;
begin
ComboBox1.Items.Clear;
for Drive := 0 to 25 do
If DriveExists(Drive) then
begin
DriveName := Chr(Drive + $41) + ':';
case GetDriveType(PChar(DriveName)) of
DRIVE_UNKNOWN: ComboBox1.Items.Add(DriveName + ' Unknown');// The drive type cannot be determined.
DRIVE_NO_ROOT_DIR: ComboBox1.Items.Add(DriveName + ' No root dir');// The root path is invalid; for example, there is no volume is mounted at the path.
DRIVE_REMOVABLE: ComboBox1.Items.Add(DriveName + ' Removable');// The drive has removable media; for example, a floppy drive or flash card reader.
DRIVE_FIXED: ComboBox1.Items.Add(DriveName + ' Fixed');// The drive has fixed media; for example, a hard drive, flash drive, or thumb drive.
DRIVE_REMOTE: ComboBox1.Items.Add(DriveName + ' Remote');// The drive is a remote (network) drive.
DRIVE_CDROM: ComboBox1.Items.Add(DriveName + ' CDRom');// The drive is a CD-ROM drive.
DRIVE_RAMDISK: ComboBox1.Items.Add(DriveName + ' Ram');// The drive is a RAM disk.
end;
end;
This is the link where barlet's code is from... ;o))
[DELPHI] - Get Drives And Types
http://www.vbforums.com/showthread.php?t=346506
[DELPHI] - Get Drives And Types
http://www.vbforums.com/showthread.php?t=346506
sorry wrong link this is the correct http://delphi.about.com/cs /adptips19 99/a/bltip 0599_5.htm :)
Just make it simple
procedure TForm1.LoadDrives;
var
C: Char;
Drive : String;
begin
for C := 'A' To 'Z' Do
begin
Drive := C + ':\';
if GetDriveType(PChar(Drive)) = DRIVE_FIXED then
ComboBox1.Items.Add(C + ':');
end;
end;
and you will have them all in Combobox :)