SetResAttrs
SetResAttrs Set resource attributes ( purgeable, locked, etc.) Handle rHandle ; handle of an existing resource short rAttrs ; desired resource attribute (bit record)
attributes will not take effect until the next time the resource is loaded.
rHandle is a resource handle. It is a handle obtained via GetResource, rAttrs is a 16-bit resource attribute word - a bit record which specifies
how the resource is to be handled when loaded subsequently (see
below).
Notes: SetResAttrs is normally needed only by resource-management utilities such as ResEdit; it is a rare application that needs to modify attributes by
using this function.
The rAttrs parameter specifies resource attributes as follows: The new setting of resProtected takes effect immediately, so make sure you
have already written any changes out to disk; other attributes take effect
the next time the resource is loaded. We are warned specifically against
modifying the state of the resChanged attribute directly. Use
A normal sequence is to use GetResAttrs to find the current settings, modifying one or more bits (without changing bit 1), then use SetResAttrs to update the resource map. This is illustrated in the following example: Example
#include <Resources.h>
short theAttr;
if ( rHandle == 0 ) { /* ... an error occurred ... */}
SetResAttrs( rHandle, theAttr | resLocked ); /* set as locked */ /* --- following code would force changes to be written to disk --*/
rHandle = GetResource( 'DanR', 128 ); /* this time it's locked */