Important: The information in this document is obsolete and should not be used for new development.
GetResAttrs
You can use theGetResAttrsfunction to get a resource's attributes.
FUNCTION GetResAttrs (theResource: Handle): Integer;
theResource- A handle to a resource.
DESCRIPTION
Given a handle to a resource, theGetResAttrsfunction returns the resource's attributes as recorded in its entry in the resource map in memory. If the value of thetheResourceparameter isn't a handle to a valid resource,GetResInfodoes nothing, and theResErrorfunction returns the result coderesNotFound.The
GetResAttrsfunction returns the resource's attributes in the low-order byte of the function result. Each attribute is identified by a specific bit in the low-order byte. If the bit corresponding to an attribute contains 1, then that attribute is set; if the bit contains 0, then that attribute is not set. You can use these constants to refer to each attribute:
CONST resSysHeap = 64; {set if read into system heap} resPurgeable = 32; {set if purgeable} resLocked = 16; {set if locked} resProtected = 8; {set if protected} resPreload = 4; {set if to be preloaded} resChanged = 2; {set if to be written to resource fork}TheresSysHeapattribute indicates whether the resource is read into the system heap (resSysHeapattribute is set to 1) or your application's heap (resSysHeapattribute is set to 0).If the
resPurgeableattribute is set to 1, the resource is purgeable; if it's 0, the resource is nonpurgeable.Because a locked resource is nonrelocatable and nonpurgeable, the
resLockedattribute overrides theresPurgeableattribute. If theresLockedattribute is 1, the resource is nonpurgeable regardless of whetherresPurgeableis set. If it's 0, the resource is purgeable or nonpurgeable depending on the value of theresPurgeableattribute.If the
resProtectedattribute is set to 1, your application can't use Resource Manager routines to change the resource ID or resource name, modify the resource contents, or remove the resource from its resource fork. However, you can use theSetResAttrsprocedure to remove this protection.If the
resPreloadattribute is set to 1, the Resource Manager reads the resource's resource data into memory immediately after opening its resource fork. You can use this setting to make multiple resources available for your application as soon as possible, rather than reading each one into memory individually. If both theresPreloadattribute and theresLockedattribute are set, the Resource Manager loads the resource as low in the heap as possible.If the
resChangedattribute is set to 1, the resource has been changed; if it's 0, the resource hasn't been changed. This attribute is used only while the resource map is in memory. TheresChangedattribute must be 0 in the resource fork on disk.RESULT CODES
noErr 0 No error resNotFound -192 Resource not found SEE ALSO
To check for errors, call theResErrorfunction as described on page 1-47.For more information about resource attributes, see "The Resource Map" beginning on page 1-7.
To change a resource's attributes in the resource map in memory, use the
SetResAttrsprocedure. It is described next.