Important: The information in this document is obsolete and should not be used for new development.
Get1NamedResource
You can use theGet1NamedResourcefunction 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
TheGet1NamedResourcefunction searches the current resource file's resource map in memory for the resource specified by the parameterstheTypeandname. IfGet1NamedResourcefinds 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 calledSetResLoadwith theloadparameter set toFALSE,Get1NamedResourceattempts to read the resource into memory.If it can't find the resource data,
Get1NamedResourcereturnsNIL, andResErrorreturns the result coderesNotFound. TheGet1NamedResourcefunction also returnsNILif the resource data to be read into memory won't fit, in which caseResErrorreturns an appropriate Memory Manager result code.If you call
Get1NamedResourcewith a resource type that can't be found in the resource map of the current resource file, the function returnsNIL, butResErrorreturns 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
UseResFileprocedure beforeGet1NamedResource.SPECIAL CONSIDERATIONS
TheGet1NamedResourcefunction 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 theResErrorfunction 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
RGetResourcefunction, described next.For information about the
UseResFileandSetResLoadprocedures, see page 1-65 and page 1-74, respectively.