Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
WhereCDs.c
/* |
** Apple Macintosh Developer Technical Support |
** |
** Sample code demonstrating detecting CD-ROM drives |
** |
** by Brian Bechtel, Apple Developer Technical Support |
** |
** File: WhereCDs.c |
** |
** Copyright © 1995 Apple Computer, Inc. |
** All rights reserved. |
** |
** You may incorporate this sample code into your applications without |
** restriction, though the sample code has been provided "AS IS" and the |
** responsibility for its operation is 100% yours. However, what you are |
** not permitted to do is to redistribute the source as "DTS Sample Code" |
** after having made changes. If you're going to re-distribute the source, |
** we require that you make it clear in the source that the code was |
** descended from Apple Sample Code, but that you've made changes. |
*/ |
#include <Devices.h> |
#include <TextUtils.h> |
#include "WhereCDs.h" |
// From tech note DV 22, CD-ROM Driver Calls. Detects drives which |
// are using the driver name ".AppleCD" in the range of driver |
// reference numbers assigned to the original SCSI bus. Will not |
// handle drives which aren't using a driver named ".AppleCD", nor |
// drives on additional SCSI buses. |
UInt8 WhereCDs() |
{ |
UInt8 where = 0; /* assume no drives handled at beginning */ |
short scsiAddress; |
short drvrRefNum; |
DCtlHandle aDCtlEntry; |
StringPtr aDriverName; |
StringPtr appleDriverName = "\p.AppleCD"; |
for (scsiAddress = 0; scsiAddress < 7; scsiAddress++) |
{ |
drvrRefNum = -33 - scsiAddress; |
aDCtlEntry = GetDCtlEntry(drvrRefNum); |
if (aDCtlEntry != nil) |
{ |
if ((**aDCtlEntry).dCtlFlags & dRAMBasedMask) |
aDriverName = (StringPtr) ((*(DCtlPtr)aDCtlEntry).dCtlDriver+18); |
else |
aDriverName = (StringPtr)((**aDCtlEntry).dCtlDriver+18); |
if ( EqualString(aDriverName, appleDriverName, false, false) == true ) |
where |= (1 << scsiAddress); |
} |
} |
return where; |
} |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-01-14