Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
Sources/Environment.cp
/* |
File: Environment.cp |
Contains: TEnvironment is a Gestalt wrapper class that finds out information about the environment. |
Environment.cp contains the member functions for the TEnvironment class. |
Written by: Kent Sandvik |
Copyright: Copyright © 1992-1999 by Apple Computer, Inc., All Rights Reserved. |
You may incorporate this Apple sample source code into your program(s) without |
restriction. This Apple sample source code has been provided "AS IS" and the |
responsibility for its operation is yours. You are not permitted to redistribute |
this Apple sample source code as "Apple sample source code" after having made |
changes. If you're going to re-distribute the source, we require that you make |
it clear in the source that the code was descended from Apple sample source |
code, but that you've made changes. |
Change History (most recent first): |
8/18/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1 |
*/ |
// INCLUDES |
#ifndef _ENVIRONMENT_ |
#include "Environment.h" |
#endif |
// _________________________________________________________________________________________________________ // |
// TEnvironment class member function implementations |
// CONSTRUCTORS & DESTRUCTORS |
#pragma segment Environment |
TEnvironment::TEnvironment() |
{ |
// Set fields to known values. |
fResult = false; |
fLongResult = 0L; |
} |
#pragma segment Environment |
TEnvironment::~TEnvironment() |
{ |
} |
// MAIN INTERFACE |
#pragma segment Environment |
Boolean TEnvironment::HasAttribute(OSType attribute, |
short theBit) |
// Generic test that takes the Gestalt attribute and the bit value, and returns a Boolean. |
{ |
return (::Gestalt(attribute, &fLongResult) == noErr) && (((fLongResult >> theBit) & 1) != 0); |
} |
#pragma segment Environment |
Boolean TEnvironment::Check128k() |
// Checks if we are running under a 128k or better ROM. |
{ |
// check if 128k ROM Macintosh or not - the framework will not work properly |
// on 64k ROM systems... |
SysEnvRec envRec; |
// ignore the error returned from SysEnvirons; even if an error occurred, |
// the SysEnvirons glue will fill in the SysEnvRec |
(void)::SysEnvirons(curSysEnvVers, &envRec); |
if (envRec.machineType < 0) // are we running on a 128K ROM machine or better??? |
return false; // we don't have a 128k System |
else |
return true; // we have a 128k System or better |
} |
#pragma segment Environment |
Boolean TEnvironment::HasAppleEvents() |
// Check if we have Apple Events support or not. |
{ |
fResult = (::Gestalt(gestaltAppleEventsAttr, &fLongResult) == noErr); |
return fResult; |
} |
#pragma segment Environment |
Boolean TEnvironment::HasColorQD() |
// Check if we have Color QuickDraw support or not. |
{ |
fResult = (::Gestalt(gestaltQuickdrawFeatures, &fLongResult) == noErr); |
return fResult; |
} |
#pragma segment Environment |
Boolean TEnvironment::IsSystemSeven() |
// Check if we are running on a System 7 version. |
{ |
::Gestalt(gestaltSystemVersion, &fLongResult);// check for system version |
if (fLongResult >= 0x0700) |
return true; |
else |
return false; |
} |
#pragma segment Environment |
Boolean TEnvironment::TrapAvailable(short aNumber, |
TrapType aType) |
// Check if the trap is implemented or not. |
{ |
// Return true if trap is available |
return (::NGetTrapAddress(aNumber, aType) != NGetTrapAddress(_Unimplemented,OSTrap)); |
} |
// _________________________________________________________________________________________________________ // |
/* Change History (most recent last): |
No Init. Date Comment |
1 khs 11/9/92 New file |
*/ |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-01-14