About the Gestalt Manager and System 7.0
About the Gestalt Manager and System 7.0
The Macintosh family of computers includes many models of computers, and it
is likely to grow in the future. Macintosh software runs on a number of
different processors, some of which are accompanied by floating- point
co processors or memory management units. In addition, the installed versions
of the system software, drivers, and QuickDraw routines may vary from
machine to machine. To ensure that your applications are maximally compatible
with existing and future versions of the Macintosh, you should keep references
to specific software and hardware features to a minimum.
In general, applications should communicate with the system software and
hardware through the available managers and device drivers. If, however, it is
necessary or useful for your applications to take advantage of software or
hardware components that may not be present on all Macintosh computers,
then you need some method of determining whether those components are
available. The Gestalt Manager serves this need by allowing you to get
information about the operating environment in a simple and efficient manner.
System 7.0 introduces several new managers and makes significant changes to
many existing managers. To take advantage of new system 7.0 features, and to
run on as many machines as possible, it is more important than ever before
that your application deter-mine the software and hardware components
available in a particular operating environment. To help you develop software
for the entire line of Macintosh computers, system 7.0 includes the
Gestalt Manager. This manager includes the Gestalt function, which is a
replacement for both the Environs procedure and the SysEnvirons function.
The Gestalt function gives your application the ability to determine
information about a large number of machine-dependent features. You can use
the Gestalt function to find the following sorts of information about the
hardware configuration and operating environment of the machine your
application is executing on:
the type of machine
the version of the System file currently running
the type of CPU
the type of keyboard attached to the machine
the type of floating-point processing unit (FPU), if any
the type of MMU, if any
the size of available RAM
the amount of available virtual memory
the versions of various drivers and managers
the features of various drivers and managers
the version of QuickDraw currently present
whether the A/UX operating system is running or not
How your application uses the resulting information depends on what your
application needs to accomplish. For example, in a case where critical
hardware features are not available, your application might display an alert
box to notify the user that the required hardware is missing and then
terminate. Or if your application has determined that Color QuickDraw is
available, it could execute alternate code to take advantage of the expanded
capabilities of that software.
Associated with the Gestalt function are two other functions-one that allows
an application to register new features with Gestalt 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 application to
announce its presence to other applications, in case they wish to alter their
actions in view of the presence of your application. For example, a macro
utility that intercepts sequences of keyboard presses and translates them into
other sequences can register itself with Gestalt at system initialization time;
afterward, other applications can call Gestalt to determine if that utility is
present. In this way, Gestalt can act as a central clearinghouse for
information on the available hardware and software features of the operating
environment, including any third-party applications that register themselves
with Gestalt. Gestalt therefore provides a further means of cooperation and
awareness among applications executing in the system 7.0 environment.
Although the Gestalt function can provide your application with most of the
basic information it needs about particular software or hardware features, you
may still need to call other routines to determine more specific features. For
example, if you need to determine the resolution of the main Macintosh screen,
you can use the Toolbox Utility procedure ScreenRes.
(See the Toolbox Utilities for a description of this procedure.)
The Gestalt function replaces both the Environs procedure and the current
implementation of the SysEnvirons function as the standard means of
determining specific aspects of the operating environment. The Gestalt
function is simpler to use and provides more information than either of those
routines. Applications that use SysEnvirons still execute correctly in system
7.0 (the SysEnvirons function calls the Gestalt function).
Use of the Environs procedure is no longer recommended because it
encourages you to think in terms of ROM versions, not in term of features that
may be available. The Gestalt Manager can also provide information such as
ROM version and size, but you should not write applications that infer the
presence of particular software or hardware features on the basis of that
information. When you need to know whether a particular feature is present,
you should request information about it directly, using the appropriate
Gestalt selector.
Although you can still call the SysEnvirons function, the
Gestalt Manager is simpler and more efficient, and is the recommended
way to get information about the operating environment. SysEnvirons
returns a system environment record containing nine different pieces of
information. Gestalt returns only the information requested by use of a
specific selector code parameter. In most cases, your application really needs
only a part of what is contained in the system environment record. With
Gestalt, your application can request only the information it needs.