Important: The information in this document is obsolete and should not be used for new development.
Get1Resource
You can use theGet1Resource
function to get resource data for a resource in the current resource file.
FUNCTION Get1Resource (theType: ResType; theID: Integer): Handle;
theType
- A resource type.
theID
- An integer that uniquely identifies a resource of the specified type.
DESCRIPTION
TheGet1Resource
function searches the current resource file's resource map in memory for the resource specified by thetheType
andtheID
parameters. IfGet1Resource
finds an entry for the resource in the current resource file's resource map and the entry contains a valid handle, it returns that handle. If the entry contains a handle whose value isNIL
, and if you haven't calledSetResLoad
with theload
parameter set toFALSE
,Get1Resource
attempts to read the resource into memory.If
Get1Resource
can't find the resource data, it returnsNIL
, andResError
returns the result coderesNotFound
. TheGet1Resource
function also returnsNIL
if the resource data to be read into memory won't fit, in which caseResError
returns an appropriate Memory Manager result code.If you call
Get1Resource
with a resource type that can't be found in the resource map of the current resource file, the function returnsNIL
, butResError
returns the result codenoErr
. You should always check that the value of the returned handle is notNIL
.You can change the resource map search order by calling the
UseResFile
procedure beforeGet1Resource
.SPECIAL CONSIDERATIONS
CallingGet1Resource
may move or purge memory blocks in the application heap. Your application should not call this function at interrupt time.RESULT CODES
noErr 0 No error resNotFound -192 Resource not found SEE ALSO
To check for errors, call theResError
function as described on page 1-47.For examples of the use of the
Get1Resource
function, see Listing 1-8 on page 1-23 and Listing 1-9 on page 1-26.To include ROM-resident system resources in the Resource Manager's search of the resource maps for open resource forks, use the
RGetResource
function as described on page 1-73.For information about the
UseResFile
andSetResLoad
procedures, see page 1-65 and page 1-74, respectively.