How to Get the Names of All Mounted Macintosh Disk Volumes (69211)



The information in this article applies to:

  • Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0
  • Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0b

This article was previously published under Q69211

SUMMARY

The following is a short demonstration program that shows how to get all the mounted disk volume names in Microsoft QuickBASIC versions 1.00, 1.00a, and 1.00b for Apple Macintosh.

MORE INFORMATION

The Macintosh File Manager keeps information about mounted disk volumes in a volume-control-block queue; each entry consists of a volume control block. A volume control block is a 178-byte nonrelocatable block that contains volume-specific information. For a description of the structure of a volume control block, see page 176 of "Inside Macintosh," Volume 4, by Apple Computer Inc. (published by Addison-Wesley).

The location of the default volume control block is &H352. The first entry in each block is a pointer to the next entry. If this value is a zero, the end of the queue has been reached. The volume name is located at bytes 44 to 70 (27 bytes long) from the head of the block.

The following is a code example:
'Program to demonstrate the use of the Volume Control Block
'       to get the names of all mounted volumes

DIM VolName$(10)        'Array to hold the names
VolCount% = 0           'Counter to hold total number of volumes
ptr& = &H352            'Pointer to default Volume Control Block
vol& = PEEKL(ptr&)      'Get pointer to next entry in queue
WHILE vol& <> 0 'Loop until null pointer
        vol& = PEEKL(ptr&)
        ptr& = vol&
        IF vol& <> 0 THEN
                VolCount% = VolCount% + 1
                x$ = ""
                st = PEEK(vol& + 44)
                FOR i = 1 TO st 'Skip i = 0 (Length of String)
                        x$=x$ + CHR$(PEEK(vol& + 44 + i))
                NEXT i
                VolName$(VolCount%) = x$
                PRINT "[";VolName$(VolCount%);"]"
                INPUT a  ' pause program using input statement
        END IF
WEND
				

Modification Type:MajorLast Reviewed:10/20/2003
Keywords:KB69211