Important: The information in this document is obsolete and should not be used for new development.
DetachResource
You can use theDetachResourceprocedure to set the value of a resource's handle in the resource map in memory toNILwhile keeping the resource data in memory.
PROCEDURE DetachResource (theResource: Handle);
theResource- A handle to a resource.
DESCRIPTION
Given a handle to a resource,DetachResourcesets the value of the resource's handle in the resource map in memory toNIL. After this call, the Resource Manager no longer recognizes the handle as a handle to a resource. However,DetachResourcedoes not release the memory used for the resource data, and the master pointer is still valid. Thus, you can access the resource data directly by using the handle.If your application subsequently calls a Resource Manager routine to get the released resource, the Resource Manager assigns a new handle. If the parameter
theResourcedoesn't contain a handle to a resource or if the resource'sresChangedattribute is set,DetachResourcedoes nothing. To determine whether either of these errors occurred, callResError.You can use
DetachResourceif you want to access the resource data directly without using Resource Manager routines. You can also use theDetachResourceprocedure to keep resource data in memory after closing a resource fork.To copy a resource and install an entry for the duplicate in the resource map, call
DetachResource, then callAddResourceusing a different resource ID.RESULT CODES
noErr 0 No error resNotFound -192 Resource not found resAttrErr -198 Attribute does not permit operation SEE ALSO
To check for errors, call theResErrorfunction as described on page 1-47.For more information about detaching resources, see "Releasing and Detaching Resources" beginning on page 1-17. For an example of the use of the
DetachResourceprocedure, see Listing 1-4 on page 1-18.For a description of the
AddResourceprocedure, see page 1-85.