whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1548)

Database (90)
Files (137)
Forms (107)
Graphic (116)
IDE (21)
Indy (5)
Internet / LAN (131)
IntraWeb (0)
Math (76)
Misc (127)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (268)
VCL (243)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

30 Visitors Online


 
...enumerate Drives on a Computer?
Autor: Thomas Stutz
[ Print tip ]  

Tip Rating (32):  
     


{
  Adds all fixed drives into Combobox1.
  To enumerate another type of drive,
  i.e all CD-ROMs just change the DRIVE_FIXED constant to DRIVE_CDROM.

  Fügt all fixen Laufwerke in Combobox1 ein.
  Um z.B alle CD-Rom Laufwerke zu ermitteln,
  einfach DRIVE_CDROM anstatt die Konstante DRIVE_FIXED nehmen.
}

procedure List_Drives;
const
  
DRIVE_UNKNOWN = 0;
  DRIVE_NO_ROOT_DIR = 1;
  DRIVE_REMOVABLE = 2;
  DRIVE_FIXED = 3;
  DRIVE_REMOTE = 4;
  DRIVE_CDROM = 5;
  DRIVE_RAMDISK = 6;
var
  
r: LongWord;
  Drives: array[0..128] of char;
  pDrive: PChar;
begin
  
r := GetLogicalDriveStrings(SizeOf(Drives), Drives);
  if r = 0 then Exit;
  if r > SizeOf(Drives) then
    raise 
Exception.Create(SysErrorMessage(ERROR_OUTOFMEMORY));
  pDrive := Drives;
  while pDrive^ <> #0 do
  begin
    if 
GetDriveType(pDrive) = DRIVE_FIXED then
      
Form1.ComboBox1.Items.Add(pDrive);
    Inc(pDrive, 4);
  end;
end;


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners