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


RemoveResource

You can use the RemoveResource procedure to remove a resource's entry from the current resource file's resource map in memory. The RemoveResource procedure is also available as the RmveResource procedure.

PROCEDURE RemoveResource (theResource: Handle);
theResource
A handle to a resource.
DESCRIPTION
Given a handle to a resource in the current resource file, RemoveResource removes the resource entry (resource type, resource ID, resource name, if any, and resource attributes) from the current resource file's resource map in memory.

The RemoveResource procedure doesn't immediately release the memory occupied by the resource data; instead, the Resource Manager releases the memory when your application quits, when you call UpdateResFile, or when you call CloseResFile (which in turn calls UpdateResFile). If the resProtected attribute for the resource is set or if the theResource parameter doesn't contain a handle to a resource, RemoveResource does nothing, and ResError returns the result code rmvResFailed.

IMPORTANT
If you've removed a resource, the Resource Manager writes the entire resource map when it updates the resource fork, and all changes made to the resource map become permanent. If you want any of the changes to be temporary, you should restore the original information before the Resource Manager updates the resource fork.
If you want to release the memory before updating or closing the resource fork, call the Memory Manager procedure DisposeHandle after you call RemoveResource.

SPECIAL CONSIDERATIONS
The RemoveResource procedure may move or purge memory blocks in the application heap. Your application should not call this procedure at interrupt time.

RESULT CODES
noErr0No error
rmvResFailed-196RemoveResource procedure failed
SEE ALSO
To check for errors, call the ResError function as described on page 1-47.

For descriptions of the AddResource and UpdateResFile procedures, see page 1-85 and page 1-87, respectively. The CloseResFile procedure is described next.

For more information about the Memory Manager procedure DisposeHandle, see Inside Macintosh: Memory.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996