Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: More Macintosh Toolbox /
Chapter 1 - Resource Manager / Resource Manager Reference
Resource Manager Routines / Disposing of Resources


DetachResource

You can use the DetachResource procedure to set the value of a resource's handle in the resource map in memory to NIL 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 to NIL. 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's resChanged attribute is set, DetachResource does nothing. To determine whether either of these errors occurred, call ResError.

You can use DetachResource if you want to access the resource data directly without using Resource Manager routines. You can also use the DetachResource 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 call AddResource using a different resource ID.

RESULT CODES
noErr0No error
resNotFound-192Resource not found
resAttrErr-198Attribute does not permit operation
SEE ALSO
To check for errors, call the ResError 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.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996