Important: The information in this document is obsolete and should not be used for new development.
DetachResource
You can use theDetachResource
procedure to set the value of a resource's handle in the resource map in memory toNIL
while keeping the resource data in memory.
PROCEDURE DetachResource (theResource: Handle);
theResource
- A handle to a resource.
DESCRIPTION
Given a handle to a resource,DetachResource
sets 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,DetachResource
does 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
theResource
doesn't contain a handle to a resource or if the resource'sresChanged
attribute is set,DetachResource
does nothing. To determine whether either of these errors occurred, callResError
.You can use
DetachResource
if you want to access the resource data directly without using Resource Manager routines. You can also use theDetachResource
procedure 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 callAddResource
using 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 theResError
function 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
DetachResource
procedure, see Listing 1-4 on page 1-18.For a description of the
AddResource
procedure, see page 1-85.