Important: The information in this document is obsolete and should not be used for new development.
OpenDriver
You can use theOpenDriver
function to open a closed device driver or to determine the driver reference number of an open device driver.
pascal OSErr OpenDriver(ConstStr255Param name, short *drvrRefNum);
name
- The name of the driver to open. A driver name consists of a period (.) followed by any sequence of 1 to 255 printing characters. The Device Manager ignores case (but not diacritical marks) when comparing names.
drvrRefNum
- The driver reference number of the opened driver.
DESCRIPTION
TheOpenDriver
function opens the device driver specified by thename
parameter and returns its driver reference number in thedrvrRefNum
parameter. To avoid replacing an open driver, the Device Manager searches the drivers that are already installed in the unit table before searching driver resources. If the specified driver is already open, this function simply returns the driver reference number.If the driver is not already open, the Device Manager calls the
GetNamedResource
function using the specified name and the resource type'DRVR'
. If the resource is found, the resource ID defines the unit number of the driver, which determines the location in the unit table where the Device Manager stores the handle to the driver's device control entry (DCE).After loading the driver resource into memory, the Device Manager creates a DCE for the driver, copies the flags from the driver header to the
dCtlFlags
field, and places the driver reference number in thedCtlRefNum
field.The
OpenDriver
function is a high-level version of the low-levelPBOpen
function. Use thePBOpen
function when you need to specify read/write permission for the driver. The next section describes thePBOpen
function.SPECIAL CONSIDERATIONS
Because another driver might already be installed in the unit table at the location determined by the driver's resource ID, you should first search for an unused location in the unit table and renumber the driver resource accordingly before calling this function. See Listing 1-1 on page 1-18 for an example.The
OpenDriver
function may move memory; you should not call it at interrupt time.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 tableopenErr -23 Requested read/write permission does not match driver's open permission dInstErr -26 Driver resource not found SEE ALSO
For information about the low-level functions for opening devices, see the next section, which describes thePBOpen
function, and the description of theOpenSlot
function on page 1-63. For an example of how to open a device driver using theOpenDriver
function, see Listing 1-1 on page 1-18.