SDL_CDOpen

Name

SDL_CDOpen -- Opens a CD-ROM drive for access.

Synopsis

uses
SDL;

function SDL_CDOpen( drive : Integer ) : PSDL_CD;

Description

Opens a CD-ROM drive for access. It returns a SDL_CD structure on success, or NULL if the drive was invalid or busy. This newly opened CD-ROM becomes the default CD used when other CD functions are passed a NULL CD-ROM handle.

Drives are numbered starting with 0. Drive 0 is the system default CD-ROM.

Examples

var
cdrom : PSDL_CD;
cur_track : integer;
min, sec, frame : integer;
CDRomText : string;
.
.
.
SDL_Init( SDL_INIT_CDROM );

/ Check for CD drives
if ( SDL_CDNumDrives < 1 ) then
begin
// None found
MessageBox( 0, 'No CDROM devices available', 'Error', MB_OK or MB_ICONHAND );
SDL_Quit;
halt( -1 );
end;

// Open the default drive
cdrom := SDL_CDOpen( 0 );

// Did if open? Check if cdrom is nil
if ( cdrom = nil ) then
begin
MessageBox( 0, PChar( Format( 'Couldn''t open drive : %s', [SDL_GetError] ) ), 'Error', MB_OK or MB_ICONHAND );
SDL_Quit;
halt( -1 );
end;

// Print Volume info
CDRomText := Format( 'Name: %s', [ SDL_CDName( 0 )] ) + #13#10;
CDRomText := CDRomText + Fromat( 'Tracks: %d', [ cdrom.numtracks ] ) + #13#10;

for cur_track := 0 to < cdrom.numtracks - 1 do
begin
FRAMES_TO_MSF( cdrom.track[cur_track].length, min, sec, frame );
CDRomText := CDRomText + Fromat( '\tTrack %d: Length %d:%d', [ cur_track, min, sec ] ) + #13#10;
end;

SDL_CDClose( cdrom );

See Also

TSDL_CD, TSDL_CDTrack, SDL_CDClose