取当前可用驱动器<br><br>返回值为一个字符串,形如'ABCD'<br>function myGetLogicalDrives : String;<br>var<br> drives : set of 0..25;<br> drive : integer;<br>begin<br> Result := '';<br> DWORD( drives ) := Windows.GetLogicalDrives;<br> for drive := 0 to 25 do<br> if drive in drives then<br> Result := Result + Chr( drive + Ord( 'A' ));<br>end;<br><br>然后判断驱动器的类型<br>procedure TForm1.Button1Click(Sender: TObject); <br>var <br> typ: Integer; <br> s: string; <br>begin <br> s := 'C:/'; <br> typ := GetDriveType(PChar(s)); <br> if Typ <> 0 then case typ of <br> DRIVE_REMOVABLE: <br> begin <br> ShowMessage('Drive Removable / Diskette'); <br> end; <br> DRIVE_FIXED: <br> begin <br> ShowMessage('Drive fixed / Festplatte'); <br> end; <br> DRIVE_CDROM: <br> begin <br> ShowMessage('CD ROM Drive'); <br> end; <br> DRIVE_RAMDISK: <br> begin <br> ShowMessage('RAM Drive'); <br> end; <br> DRIVE_REMOTE: <br> begin <br> ShowMessage('Remote Drive / Netzlaufwerk'); <br> end; <br> end; <br>end;