Главная страница | назад





Article #17266: Determining Drive Type

 Question and Answer Database
FAQ2266D.txt Determining Drive Type
Category :Windows API
Platform :All
Product :All 32 bit
Question:
How can my application tell if a given drive is a CD, Network,
Ramdisk, or Removable drive?
Answer:
Use the Windows API function GetDriveType().
Example:
procedure TForm1.Button1Click(Sender: TObject);
begin
case GetDriveType('C:\') of
0 : ShowMessage('The drive type cannot be determined');
1 : ShowMessage('The root directory does not exist');
DRIVE_REMOVABLE:ShowMessage('The disk can be removed');
DRIVE_FIXED : ShowMessage('The disk cannot be removed');
DRIVE_REMOTE : ShowMessage('The drive is remote (network) drive');
DRIVE_CDROM : ShowMessage('The drive is a CD-ROM drive');
DRIVE_RAMDISK : ShowMessage('The drive is a RAM disk');
end;
end;
7/16/98 4:31:28 PM

Last Modified: 01-SEP-99