Important: The information in this document is obsolete and should not be used for new development.
CloseDriver
You can use theCloseDriverfunction to close an open device driver.
pascal OSErr CloseDriver(short refNum);
refNum- The driver reference number returned by the driver-opening function.
DESCRIPTION
TheCloseDriverfunction closes the device driver indicated by therefNumparameter. 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 thedRAMBasedflag is set, and unlocks the device control entry if thedNeedLockflag is not set. The Device Manager does not dispose of the device control entry or remove it from the unit table.This function is a high-level version of the low-level
PBClosefunction. Use thePBClosefunction when you want to specify a completion routine.
- 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
CloseDriverfunction 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.![]()
RESULT CODES
noErr 0 No error badUnitErr -21 Driver reference number does not match unit table unitEmptyErr -22 Driver reference number specifies a nilhandle in unit tableclosErr -24 Driver unable to complete close request dRemovErr -25 Attempt to remove an open driver SEE ALSO
For information about the low-level function for closing device drivers, see the next section, which describes thePBClosefunction.