Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Operating System Utilities /
Chapter 1 - Gestalt Manager


About the Gestalt Manager

The Macintosh family of computers includes models that use a number of different processors, some accompanied by a floating-point unit (FPU) or memory management unit (MMU). Also, a single hardware configuration can have various versions of system software, drivers, and QuickDraw routines.

In general, applications should communicate with the system software and hardware through the available managers and device drivers. However, if your application takes advantage of hardware or software components that may not be present on all Macintosh computers, then you need some mechanism to determine whether those components are available.

The Gestalt function provides a simple, efficient way to determine the hardware and software configurations so your application can exploit as fully as possible whatever environment it is running in. When your application calls the Gestalt function, your application passes a selector code (or selector) as a parameter to specify the information it needs. Your application can call the Gestalt function to determine

Your application can use the information returned by Gestalt in various ways. It might branch to alternate code, for example, depending on the version of QuickDraw, or cancel an operation and present an alert box if a critical but optional hardware component is unavailable.

Associated with the Gestalt function are two other functions--one that allows an application to register new features with the Gestalt Manager and another that allows an application to change the function used by Gestalt to retrieve a particular piece of information. These two functions make it easy for your software to announce its presence to other applications. A debugger, for example, can register itself with the Gestalt Manager during system initialization; afterward, debugging code in an application under development can call Gestalt to verify that the special routines provided by the debugger are available on the local machine. In this way, the Gestalt Manager can act as a central clearinghouse for information on the available software and hardware features of the operating environment and enhance cooperation and awareness among third-party products.

Although the Gestalt function can provide much of the information your application needs, you might still need to call some special-purpose routines supplied by various parts of the system software. To determine the resolution of the main Macintosh screen, for example, you call the ScreenRes procedure, described in the book Inside Macintosh: Imaging with QuickDraw.

The Gestalt function has replaced both the SysEnvirons function and the Environs procedure. The Gestalt function is simpler to use and provides more information than either of those routines. Applications that use SysEnvirons execute correctly in system software versions 7.0 and later, in which SysEnvirons calls Gestalt.

The SysEnvirons function, introduced with the Macintosh SE and Macintosh II computers, fills in and returns a pointer to a system environment record, a data structure that describes some features of the operating environment. The SysEnvirons function cannot provide the detailed information supplied by Gestalt.

Like the SysEnvirons function, Gestalt can provide objective configuration information such as ROM version and size, but you should not infer the presence or absence of particular hardware or software features from that information. When you need to know whether a feature is present, you should request information about it directly by using the appropriate selector code. ("Getting Information About the Operating Environment" beginning on page 1-6, lists the Apple-defined selector codes for Gestalt.)


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996