DelphiFAQ Home Search:
General :: Windows :: Programming :: Windows with Delphi :: Windows Filesystem
File related questions and answers. File operations, attributes, system dialogs, hard disk handling.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Only the 40 most recently viewed articles are shown.
You can see the full list here.

Featured Article

Detecting a CDROM and other drives (newer Windows versions)

The following code enumerates the drives on the local computer using the Windows API GetDriveType. This function was introduced with Windows 95 already, so there is no need to use the other code posted on this site (which was written for Windows 3.1 and worked until Windows 98).

procedure TForm1.Button1Click(Sender: TObject);
 var
   i,
   iType: integer;
   s: String;
 begin { TForm1.Button1Click }
   for i := 0 to 25 do
   begin
     s := Chr(i + 65) + ':';
     iType := GetDriveType(PChar(s));
     case iType of
       DRIVE_REMOVABLE:
         ListBox1.Items.Add(Chr(i + 65) + ': floppy');
       DRIVE_FIXED:
         ListBox1.Items.Add(Chr(i + 65) + ': hard disk');
       DRIVE_CDROM:
         ListBox1.Items.Add(Chr(i + 65) + ': CDROM');
       DRIVE_RAMDISK:
         ListBox1.Items.Add(Chr(i + 65) + ': RAMDisk');
       DRIVE_REMOTE:
         ListBox1.Items.Add(Chr(i + 65) + ': network drive');
     end; { case iType }
   end; { for i }
 end; { TForm1.Button1Click }
 
You don't like the formatting? Check out SourceCoder then!
Generated 16:02:01 on Jul 21, 2018