为什么不看前面的问题呢?
为了得分,只好再贴一次!
关键是GetDriveType函数
TDriveType = (dtUnknown, dtNoDrive, dtFloppy, dtFixed, dtNetwork, dtCDROM,
dtRAM);
function GetCDROMNumber:integer;
var
DriveNum: Integer;
DriveChar: Char;
DriveType: TDriveType;
DriveBits: set of 0..25;
begin
result := 0;
Integer(DriveBits) := GetLogicalDrives;
for DriveNum := 2 to 25do
begin
if not (DriveNum in DriveBits) then
Continue;
DriveChar := Char(DriveNum + Ord('A'));
DriveType := TDriveType(GetDriveType(PChar(DriveChar + ':/')));
if DriveType = dtCDROM then
Inc(result);
end;
end;
function isCDROM(DriveNum:Integer):Boolean;
var
//DriveNum: Integer;
DriveChar: Char;
DriveType: TDriveType;
DriveBits: set of 0..25;
begin
result := False;
Integer(DriveBits) := GetLogicalDrives;
if (DriveNum in DriveBits) then
begin
DriveChar := Char(DriveNum + Ord('A'));
DriveType := TDriveType(GetDriveType(PChar(DriveChar + ':/')));
if DriveType = dtCDROM then
result:=True;
end;
end;