SDL: Ejecting a CDROM

Started by José Roca, July 27, 2008, 11:09:47 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca

 
The following example illustrates the use of the SDL_CDEject function.


#COMPILE EXE
#DIM ALL
#INCLUDE "SDL.INC"

FUNCTION PBMAIN () AS LONG

   ' Initialize SDL
   IF SDL_Init(%SDL_INIT_CDROM) < 0 THEN
      ? "Couldn't initialize SDL" & SDL_GetError
      #IF %DEF(%PB_CC32)
         WAITKEY$
      #ENDIF
      EXIT FUNCTION
   END IF

   LOCAL pcdrom AS SDL_CD PTR
   pcdrom = SDL_CDOpen(0)
   IF pcdrom = %NULL THEN
      ? "Couldn't open default CD-ROM drive: " & SDL_GetError
      #IF %DEF(%PB_CC32)
         WAITKEY$
      #ENDIF
      SDL_Quit
      EXIT FUNCTION
   END IF

   ' Eject the CD Rom
   IF SDL_CDEject(pcdrom) = 0 THEN
      ? "CDRom ejected"
   END IF

   ' Close the SDL_CD handle
   SDL_CDClose(pcdrom)

   ' Shut down SDL
   SDL_Quit

   #IF %DEF(%PB_CC32)
      WAITKEY$
   #ENDIF

END FUNCTION

  •