• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Gestalt
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Gestalt


  • Subject: Re: Gestalt
  • From: koko <email@hidden>
  • Date: Wed, 21 Sep 2011 13:45:38 -0600

When a user buys we ask for a registration on first run.  We like to get the OS name and version number from their system to include in out reg database.

I just want to be sure that using Gestalt will not break in the future or is there a better way than that below to get the OS version.

- (void) getSystemVersionMajor:(unsigned *)major minor:(unsigned *)minor bugFix:(unsigned *)bugFix {

	OSErr err;
    SInt32 systemVersion, versionMajor, versionMinor, versionBugFix;
    if ((err = Gestalt(gestaltSystemVersion, &systemVersion)) != noErr) goto fail;
    if (systemVersion < 0x1040)
    {
        if (major) *major = ((systemVersion & 0xF000) >> 12) * 10 +
            ((systemVersion & 0x0F00) >> 8);
        if (minor) *minor = (systemVersion & 0x00F0) >> 4;
        if (bugFix) *bugFix = (systemVersion & 0x000F);
    }
    else
    {
        if ((err = Gestalt(gestaltSystemVersionMajor, &versionMajor)) != noErr) goto fail;
        if ((err = Gestalt(gestaltSystemVersionMinor, &versionMinor)) != noErr) goto fail;
        if ((err = Gestalt(gestaltSystemVersionBugFix, &versionBugFix)) != noErr) goto fail;
        if (major) *major = versionMajor;
        if (minor) *minor = versionMinor;
        if (bugFix) *bugFix = versionBugFix;
    }

    return;

fail:
    NSLog(@"Unable to obtain system version: %ld", (long)err);
    if (major) *major = 10;
    if (minor) *minor = 0;
    if (bugFix) *bugFix = 0;
}

-koko





On Sep 21, 2011, at 1:32 PM, Sean McBride wrote:

> On Wed, 21 Sep 2011 13:26:32 -0600, koko said:
>
>> Is Gestalt(gestaltSystemVersion, &MacVersion) the wat toget OSX versions
>> today and moving forward?
>
> No.  Because it's BCD and breaks for values larger than 9.  See Gestalt.h.  Instead, use:
>
> 	SInt32 major = 0;
> 	(void)Gestalt (gestaltSystemVersionMajor, &major);
>
> 	SInt32 minor = 0;
> 	(void)Gestalt (gestaltSystemVersionMinor, &minor);
>
> 	SInt32 fix = 0;
> 	(void)Gestalt (gestaltSystemVersionBugFix, &fix);
>
> Cheers,
>
> --
> ____________________________________________________________
> Sean McBride, B. Eng                 email@hidden
> Rogue Research                        www.rogue-research.com
> Mac Software Developer              Montréal, Québec, Canada
>
>
>

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Gestalt
      • From: Sean McBride <email@hidden>
References: 
 >Gestalt (From: koko <email@hidden>)
 >Re: Gestalt (From: Sean McBride <email@hidden>)

  • Prev by Date: Re: Symbolic Breakpoints
  • Next by Date: Re: Symbolic Breakpoints
  • Previous by thread: Re: Gestalt
  • Next by thread: Re: Gestalt
  • Index(es):
    • Date
    • Thread