Important: The information in this document is obsolete and should not be used for new development.
RGetResource
You can use theRGetResource
function to get resource data for a resource and include ROM-resident system resources in the Resource Manager's search of resource maps.
FUNCTION RGetResource (theType: ResType; theID: Integer): Handle;
theType
- A resource type.
theID
- An integer that uniquely identifies a resource of the specified type.
DESCRIPTION
TheRGetResource
function searches the resource maps in memory for the resource specified by the parameterstheType
andtheID
. The resource maps in memory, which represent all open resource forks, are arranged as a linked list. TheRGetResource
function first usesGetResource
to search this list. TheGetResource
function starts with the current resource file and progresses through the list in order (that is, in reverse chronological order in which the resource forks were opened) until it finds the resource's entry in one of the resource maps. IfGetResource
doesn't find the specified resource in its search of the resource maps of open resource forks (which includes the System file's resource fork),RGetResource
sets the global variableRomMapInsert
toTRUE
, then callsGetResource
again. In response,GetResource
performs the same search, but this time it looks in the resource map of the ROM-resident resources before searching the resource map of the System file.If
RGetResource
finds the specified resource entry in one of the resource maps and the entry contains a valid handle, the function returns that handle. If the entry contains a handle whose value isNIL
, and if you haven't calledSetResLoad
with theload
parameter set toFALSE
,RGetResource
attempts to read the resource into memory.If it can't find the resource data,
RGetResource
returnsNIL
, andResError
returns the result coderesNotFound
. TheRGetResource
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 callRGetResource
with a resource type that can't be found in any of the resource maps of the open resource forks, the function returnsNIL
, butResError
returns the result codenoErr
. You should always check that the value of the returned handle is notNIL
.SPECIAL CONSIDERATIONS
TheRGetResource
function 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 more information, see "Inserting the ROM Resource Map" beginning on page 1-128.
For a description of the
UseResFile
procedure, see page 1-65. TheSetResLoad
procedure is described next.