Hmm... Applescript might be the best way to go.
But here is something I have, too...
This is ugly, but it works...
dim ParamBlock, DriveRefNum as memoryBlock
dim i as integer
dim osErr as integer
ParamBlock=newMemoryBlock(50)
DriveRefNum=newMemoryBlock(4)
// Note that OpenDriver is not "Carbon Compliant"
// You can use PBOpen, which is compliant, but more involved
Declare Function OpenDriver Lib "InterfaceLib" (name as PString,
drvrRefNum as Ptr) as Short // no Inline68K code available for this function
Declare Function PBControlSync Lib "InterfaceLib" (paramBlock as Ptr)
as Short Inline68K("205FA0043E80")
// Get the drive reference number
osErr=OpenDriver(".AppleCD", DriveRefNum)
if osErr<0 then
msgBox "Error performing OpenDriver:"+Str(osErr)
return
end if
// Build the ParamBlock
// ioCompletion
ParamBlock.long(12)=0
// ioRefNum -- Device reference number
ParamBlock.short(24)=DriveRefNum.short(0)
// csCode
ParamBlock.short(26)=7 // EjectTheDisc
// csParam -- Control or status information for the call
for i=28 to 40
ParamBlock.byte(i)=0
next
// ioResult -- Error code (0=no error, 1=not done yet)
// This is just a spot for return info
// ioVRefNum -- Drive identification
ParamBlock.short(22)=1 // assumes only 1 CD-ROM drive is attached
// The actual call ----------------------
osErr=PBControlSync(ParamBlock)
===================================================
This stuff is detailed in Apple technote dv22.pdf.
However, as someone pointed out to me recently, for MacOS X we need to
start using the IOKit. I haven't done that one yet...
Paul Kaiser
|