Posted By

Zydeco on 10/11/09


Tagged

cocoa mac osx version carbon


Versions (?)

Mac OS X System Version


 / Published in: C
 

Full Mac OS X system version Returns the full Mac OS X system version, as MMmmff

Example:

  • 10.0.1 returns 100001
  • 10.4.2 returns 100402
  • 10.4.11 returns 100411
  • 10.5.3 returns 100503

It's different from gestaltSystemVersion in that this supports minor and bug fix revisions larger than 9.

  1. int getSystemVersion(void)
  2. {
  3. /* system version as MMmmff */
  4. OSErr err;
  5. long vMaj, vMin, vFix, version;
  6.  
  7. err = Gestalt(gestaltSystemVersionMajor, &vMaj);
  8. if (err != noErr) {
  9. // must use old selector
  10. err = Gestalt(gestaltSystemVersion, &version);
  11. if (err != noErr) return 0;
  12. vMaj = ((version & 0xF000) >> 12) * 10 + ((version & 0x0F00) >> 8);
  13. vMin = (version & 0x00F0) >> 4;
  14. vFix = (version & 0x000F);
  15. }
  16. else {
  17. // get version numbers this way (10.4 and above)
  18. err = Gestalt(gestaltSystemVersionMinor, &vMin);
  19. if (err != noErr) return 0;
  20. err = Gestalt(gestaltSystemVersionBugFix, &vFix);
  21. if (err != noErr) return 0;
  22. }
  23.  
  24. return (vMaj * 10000) + (vMin * 100) + vFix;
  25. }

Report this snippet  

You need to login to post a comment.