Important: The information in this document is obsolete and should not be used for new development.
Get1NamedResource
You can use theGet1NamedResource
function to get a named resource in the current resource file.
FUNCTION Get1NamedResource (theType: ResType; name: Str255) : Handle;
theType
- A resource type.
name
- A name that uniquely identifies a resource of the specified type.
DESCRIPTION
TheGet1NamedResource
function searches the current resource file's resource map in memory for the resource specified by the parameterstheType
andname
. IfGet1NamedResource
finds an entry for the resource in the current resource file's resource map 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
,Get1NamedResource
attempts to read the resource into memory.If it can't find the resource data,
Get1NamedResource
returnsNIL
, andResError
returns the result coderesNotFound
. TheGet1NamedResource
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
Get1NamedResource
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 search order by calling the
UseResFile
procedure beforeGet1NamedResource
.SPECIAL CONSIDERATIONS
TheGet1NamedResource
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.To include ROM-resident system resources in the Resource Manager's search of the resource maps for open resource forks, use the
RGetResource
function, described next.For information about the
UseResFile
andSetResLoad
procedures, see page 1-65 and page 1-74, respectively.