开发者

How to programmatically detect Mac OS X Server Edition?

开发者 https://www.devze.com 2022-12-27 13:22 出处:网络
Is anybody knows any API that can help to distinguish Mac OS X \"Server edition\" from \"Desktop edition\"?

Is anybody knows any API that can help to distinguish Mac OS X "Server edition" from "Desktop edition"? My application should know on which edition of Mac OS X it currently running. 开发者_高级运维(Server or Desktop)


sw_vers appears to do it by checking /System/Library/CoreServices/ServerVersion.plist -- you could probably get by with just seeing if the file exists.


If there is a real reason why your application needs to know this, I'd recommend checking for the existence of the component that makes the difference on desktop/server. For example, if the server version comes with the program or library foo and the desktop version doesn't, and you would like to use foo, then check for the existence (and/or version of) foo instead of trying to infer it from Server vs Desktop OS.

(Meanwhile, one possible starting point to check the OS version are the commands sw_vers and system_profiler SPSoftwareDataType.)


Maybe you can find a difference using the sysctl API, or Gestalt

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号