Important: The information in this document is obsolete and should not be used for new development.
SetResInfo
You can use theSetResInfo
procedure to change the name and resource ID of a resource.
PROCEDURE SetResInfo (theResource: Handle; theID: Integer; name: Str255);
theResource
- A handle to a resource.
theID
- The new resource ID.
name
- The new name or an empty string to preserve the resource name.
DESCRIPTION
Given a handle to a resource,SetResInfo
changes the resource ID and the resource name of the specified resource to the values given intheID
andname
. If you pass an empty string for thename
parameter, the resource name is not changed. TheSetResInfo
procedure changes the information in the resource map in memory, not in the resource file itself.
If the parameter
- WARNING
- Do not change a system resource's resource ID or name. Other applications may already access the resource and may not work properly if you change the resource ID, resource name, or both.
theResource
doesn't contain a handle to an existing resource,SetResInfo
does nothing, andResError
returns the result coderesNotFound
. If
the resource map becomes too large to fit in memory (for example, after an unnamed resource is given a name),SetResInfo
does nothing, andResError
returns an appropriate Memory Manager result code. The same is true if the resource data in memory can't be written to the resource fork (for example, because the disk is full). If theresProtected
attribute is set for the resource,SetResInfo
does nothing, andResError
returns the result coderesAttrErr
.If you want to write changes to the resource map on disk after updating the resource map in memory, call the
ChangedResource
procedure for the same resource after you callSetResInfo
.
- IMPORTANT
- Even if you don't call
ChangedResource
after usingSetResInfo
to change the name and resource ID of a resource, the change may be written to disk when the Resource Manager updates the resource fork. If you callChangedResource
for any resource in the same resource fork, or if you add or remove a resource, the Resource Manager writes the entire resource map to disk after a call toUpdateResFile
or when your application terminates. In these cases, all changes to resource information in the resource map become permanent. If you want any of the changes to be temporary, you should restore the original information before the resource is updated.SPECIAL CONSIDERATIONS
TheSetResInfo
procedure may move or purge memory blocks in the application heap. Your application should not call this procedure at interrupt time.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 a description of the
ChangedResource
andUpdateResFile
procedures, see page 1-83 and page 1-87, respectively.