取当前可用驱动器
返回值为一个字符串,形如'ABCD'
function myGetLogicalDrives : String;
var
drives : set of 0..25;
drive : integer;
begin
Result := '';
DWORD( drives ) := Windows.GetLogicalDrives;
for drive := 0 to 25 do
if drive in drives then
Result := Result + Chr( drive + Ord( 'A' ));
end;
*********************
取的有效驱动器
API函数
DWORD GetLogicalDrives(VOID);
DWORD GetLogicalDriveStrings(
DWORD nBufferLength, // size of buffer
LPTSTR lpBuffer // drive strings buffer
);
UINT GetDriveType(
LPCTSTR lpRootPathName // root directory
);
******************
AvailableDrives :dword;
AvailableDrives := GetLogicalDrives;
for i:= 0 to 25 do
if GetBit(AvailableDrives,i+1)=1 then//如果驱动器存在
begin
DrivePath:=Char(Ord('A')+i)+':\';
case GetDriveType(pchar(DrivePath)) of
DRIVE_FIXED :....//如果是硬盘
DRIVE_......
end;
end;