Detect CD-Rom drive

 BBS: Inland Empire Archive
Date: 11-23-92 (08:31)             Number: 392
From: FRANCOIS ROY                 Refer#: NONE
  To: DAVID SOLLY                   Recvd: NO  
Subj: Detect CD-Rom drive            Conf: (2) Quik_Bas
DS>Could someone please tell me if it is possible to write a Q[ick]Basic
DS>routine to detect the presence of a CD-ROM drive and, more specifically,
DS>to detect if the drive is ready?  Thank you very much.

   TYPE REGTYPE  ' For CALL INTERRUPT
     AX AS INTEGER
     BX AS INTEGER
     CX AS INTEGER
     DX AS INTEGER
     BP AS INTEGER
     SI AS INTEGER
     DI AS INTEGER
     FL AS INTEGER
     DS AS INTEGER
     ES AS INTEGER
   END TYPE
   DIM SHARED INR AS REGTYPE, OUR AS REGTYPE

  SUB CDDRIVE (DR$) STATIC
    DR$ = STRING$(32, 0)
    INR.AX = &H150D
    INR.BX = SADD(DR$)
    INR.ES = SSEG(DR$)
    CALL INTERRUPTX(&H2F, INR, OUR)
    IF ASC(DR$) = 0 THEN DR$ = "" ELSE DR$ = CHR$(ASC(DR$) + 65) + ":"
  END SUB

 The CALL INTERRUPTX requires the presence of the MS-Dos CD-Rom Extensions.
 The call can actually return more than one drive letters if many drives are
 attached; the simple CDDRIVE subroutine will only return the first one.
 Note that the drive letter (if any) returned when you CALL CDDRIVE(DR$) only
 indicates a drive is available.  To test if it is ready, you have to attempt
 to open a file (ANY file - doesn't matter if it exists or not) and trap the
 error code: The 'Disk Not Ready' code is 71.



--- ME2_1104
 * Origin: Out of String Space - the Final Frontier (Fidonet 1:163/506.2)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET