...das erste/die Anzahl CD-Rom Laufwerk(e) ermitteln?
Autor: Thomas Stutz
function GetFirstCDROMDrive: char;
var
drivemap, mask: DWORD;
i: integer;
root: string;
begin
Result := #0;
root := 'A:\';
drivemap := GetLogicalDrives;
mask := 1;
for i := 1 to 32 do
begin
if (mask and drivemap) <> 0 then
if GetDriveType(PChar(root)) = DRIVE_CDROM then
begin
Result := root[1];
Break;
end;
mask := mask shl 1;
Inc(root[1]);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ShowMessage(GetFirstCDROMDrive);
end;
{********************************}
function GetNumberOfCDDrives: Byte;
var
drivemap, mask: DWORD;
i: integer;
root: string;
begin
Result := 0;
root := 'A:\';
drivemap := GetLogicalDrives;
mask := 1;
for i := 1 to 32 do
begin
if (mask and drivemap) <> 0 then
if GetDriveType(PChar(root)) = DRIVE_CDROM then
begin
Inc(Result);
end;
mask := mask shl 1;
Inc(root[1]);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption := IntToStr(GetNumCDDrives);
end;
printed from
www.swissdelphicenter.ch
developers knowledge base