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

Previous Book Contents Book Index Next

Inside Macintosh: Operating System Utilities /
Chapter 1 - Gestalt Manager / Gestalt Manager Reference
Gestalt Manager Routines / Getting Information About the Operating Environment


You can use the Gestalt function to obtain information about the operating environment. You specify what information you need by passing one of the selector codes recognized by Gestalt.

FUNCTION Gestalt (selector: OSType; VAR response: LongInt): OSErr;
The selector code for the information you need.
On exit, the requested information whose format depends on the selector code specified in the selector parameter.
The Gestalt function places the information requested by the selector parameter in the variable parameter response. Note that Gestalt returns the response from all selectors in a long word, which occupies 4 bytes. When not all 4 bytes are needed, the significant information appears in the low-order byte or bytes. Although the response parameter is declared as a variable parameter, you cannot use it to pass information to Gestalt or to a Gestalt selector function. Gestalt interprets the response parameter as an address at which it is to place the result returned by the selector function specified by the selector parameter. Gestalt ignores any information already at that address.

The Apple-defined selector codes fall into two categories: environmental selectors, which supply specific environmental information you can use to control the behavior of your application, and informational selectors, which supply information you can't use to determine what hardware or software features are available. You can use one of the selector codes defined by Apple (listed in the "Constants" section beginning on page 1-14) or a selector code defined by a third-party product.

Selectors with the suffix Attr return a 32-bit response value in which the individual bits represent specific attributes. The constants listed for these response values represent bit numbers.

When passed one of the Apple-defined selector codes, the Gestalt function does not move or purge memory and therefore may be called at any time, even at interrupt time. However, selector functions associated with non-Apple selector codes might move or purge memory, and third-party software can alter the Apple-defined selector functions. Therefore, it is safest always to assume that Gestalt could move or purge memory.

The registers on entry and exit for the Gestalt function are
Registers on entry
D0Selector code
Registers on exit
D0Result code

noErr0No error
gestaltUnknownErr-5550Could not obtain the response
gestaltUndefSelectorErr-5551Undefined selector
See the documentation of the features you're interested in for more information on the various response values and their meanings.

See "Interpreting Gestalt Responses" beginning on page 1-9 for a discussion of the different response value formats and a sample function that checks an attributes value for a specific feature.

See "Getting Information About the Operating Environment" beginning on page 1-6 for a sample function that calls the Gestalt function and checks the validity of the return value. See the "Constants" section beginning on page 1-14 for a list of selector codes defined by Apple and the formats of their responses.

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.

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