如何以编程方式确定运行的Mac

如何以编程方式确定运行的Mac

本文介绍了如何以编程方式确定运行的Mac OS X版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序,需要在Tiger上的行为略有不同,比豹。任何人都知道一个系统调用,这将允许我准确地确定我正在运行的Mac OS X的版本。我找到了一些宏定义来确定构建机器的操作系统,但没有什么真正好确定正在运行的机器的操作系统。

I have a program which needs to behave slightly differently on Tiger than on Leopard. Does anybody know of a system call which will allow me to accurately determine which version of Mac OS X I am running. I have found a number of macro definitions to determine the OS of the build machine, but nothing really good to determine the OS of the running machine.

谢谢,
Joe

Thanks,Joe

推荐答案

但总之,如果你使用碳,使用Gestalt()调用,如果你使用可可,有一个称为NSAppKitVersionNumber的常量,你可以简单地检查。

But in short, if you're using carbon, use the Gestalt() call, and if you're using cocoa, there is a constant called NSAppKitVersionNumber which you can simply check against.

编辑:对于Mac OSX 10.8及以上, Gestalt()了。有关更多详细信息,请参阅此答案:

Edit: For Mac OSX 10.8 and above, don't use Gestalt() anymore. See this answer for more details: How do I determine the OS version at runtime in OS X or iOS (without using Gestalt)?

这篇关于如何以编程方式确定运行的Mac OS X版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 02:20