Important: The information in this document is obsolete and should not be used for new development.
PBClose
You can use thePBClose
function to close an open device driver.
pascal OSErr PBClose(ParmBlkPtr paramBlock, Boolean async);
paramBlock
- A pointer to an
IOParam
structure of the Device Manager parameter block.async
- A Boolean value that indicates whether the request is asynchronous. You must set this field to
false
because device drivers cannot be closed asynchronously.
<-- ioResult OSErr The device driver's result code. --> ioRefNum short The driver reference number. DESCRIPTION
ThePBClose
function closes the device driver specified by theioRefNum
field. The Device Manager waits until the driver is inactive before calling the driver's close routine. When the driver indicates it has processed the close request, the Device Manager unlocks the driver resource if thedRAMBased
flag is set, and unlocks the device control entry if thedNeedLock
flag is not set. The Device Manager does not dispose of the device control entry or remove it from the unit table.If the driver returns a negative result in register D0, the Device Manager returns this result code in the
ioResult
field of the parameter block and does not close the driver.
- WARNING
- You should not close drivers that other applications may be using, such as a disk driver, the AppleTalk drivers, and so on.
SPECIAL CONSIDERATIONS
The Device Manager does not queue close requests.
- WARNING
- Do not call the
PBClose
function at interrupt time because if the driver was processing a request when the interrupt occurred the Device Manager may loop indefinitely, waiting for the driver to complete the request.ASSEMBLY-LANGUAGE INFORMATION
The trap macro for thePBClose
function is_Close
(0xA001).You must set up register A0 with the address of the parameter block. When
_Close
returns, register D0 contains the result code. Register D0 is the only register affected by this function.
Registers on entry A0 Address of the parameter block
Registers on exit D0 Result code RESULT CODES
noErr 0 No error badUnitErr -21 Driver reference number does not match unit table unitEmptyErr -22 Driver reference number specifies a nil
handle in unit tableclosErr -24 Driver unable to complete close request dRemovErr -25 Attempt to remove an open driver SEE ALSO
For information about the high-level function for closing device drivers, see the description of theCloseDriver
function on page 1-65. For an example of how to close a device driver using thePBClose
function, see Listing 1-2 on page 1-20.