Mega Code Archive

 
Categories / Delphi / Multimedia
 

Get a list of CD ROM drives

Title: Get a list of CD ROM drives Question: How can I get all CD ROM drives? Answer: Create a function that return a string similar to the following: Function GetCDList : String; Var I : Integer; Drives: Integer; Tmp : String; begin Drives := GetLogicalDrives; Result := ''; // units A=0 to el Z=25 For I := 0 To 25 Do If (((1 Shl I) And Drives)0) Then Begin Tmp := Char(65+I)+':\'; If (GetDriveType(PChar(Tmp))=DRIVE_CDROM) Then Result := Result+Char(65+I); End; End; The result is a String with the letters of CD-ROM units (drives), you can separate it with copy function. Regards