whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

28 Visitors Online


 
...determine the first/the number of CD-Rom Drive(s)?
Autor: Thomas Stutz
[ Print tip ]  

Tip Rating (4):  
     


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;

 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners