Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

Previous Book Contents Book Index Next

Inside Macintosh: More Macintosh Toolbox /
Chapter 1 - Resource Manager / Resource Manager Reference
Resource Manager Routines / Reading Resources Into Memory


Get1Resource

You can use the Get1Resource 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
The Get1Resource function searches the current resource file's resource map in memory for the resource specified by the theType and theID parameters. If Get1Resource 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 is NIL, and if you haven't called SetResLoad with the load parameter set to FALSE, Get1Resource attempts to read the resource into memory.

If Get1Resource can't find the resource data, it returns NIL, and ResError returns the result code resNotFound. The Get1Resource function also returns NIL if the resource data to be read into memory won't fit, in which case ResError 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 returns NIL, but ResError returns the result code noErr. You should always check that the value of the returned handle is not NIL.

You can change the resource map search order by calling the UseResFile procedure before Get1Resource.

SPECIAL CONSIDERATIONS
Calling Get1Resource may move or purge memory blocks in the application heap. Your application should not call this function at interrupt time.

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 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 and SetResLoad procedures, see page 1-65 and page 1-74, respectively.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996

Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2004 Apple Computer, Inc.
All rights reserved. | Terms of use | Privacy Notice