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 / Getting and Setting Resource Information


GetResAttrs

You can use the GetResAttrs function to get a resource's attributes.

FUNCTION GetResAttrs (theResource: Handle): Integer;
theResource
A handle to a resource.
DESCRIPTION
Given a handle to a resource, the GetResAttrs function returns the resource's attributes as recorded in its entry in the resource map in memory. If the value of the theResource parameter isn't a handle to a valid resource, GetResInfo does nothing, and the ResError function returns the result code resNotFound.

The GetResAttrs function 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}
The resSysHeap attribute indicates whether the resource is read into the system heap (resSysHeap attribute is set to 1) or your application's heap (resSysHeap attribute is set to 0).

If the resPurgeable attribute 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 resLocked attribute overrides the resPurgeable attribute. If the resLocked attribute is 1, the resource is nonpurgeable regardless of whether resPurgeable is set. If it's 0, the resource is purgeable or nonpurgeable depending on the value of the resPurgeable attribute.

If the resProtected attribute 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 the SetResAttrs procedure to remove this protection.

If the resPreload attribute 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 the resPreload attribute and the resLocked attribute are set, the Resource Manager loads the resource as low in the heap as possible.

If the resChanged attribute 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. The resChanged attribute must be 0 in the resource fork on disk.

RESULT CODES
noErr0No error
resNotFound-192Resource not found
SEE ALSO
To check for errors, call the ResError function 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 SetResAttrs procedure. It is described next.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996