开发者

Read system information using macruby or ruby cocoa

开发者 https://www.devze.com 2022-12-20 02:20 出处:网络
Could someone t开发者_JS百科ell me please how to read system information, such as OS version, versions of installed applications, and hardware details, using MacRuby or RubyCocoa?You might be able to

Could someone t开发者_JS百科ell me please how to read system information, such as OS version, versions of installed applications, and hardware details, using MacRuby or RubyCocoa?


You might be able to find what you need with NSProcessInfo:

>> NSProcessInfo.processInfo.operatingSystemVersionString
=> "Version 10.6.2 (Build 10C540)"
>> NSProcessInfo.processInfo.processorCount
=> 2
>> NSProcessInfo.processInfo.physicalMemory
=> 4294967296

Check out the Mac Dev Center for more.


For the exhaustive apps and versions you can call

/usr/sbin/system_profiler

Read the man page first. Parse what you need. One challenge you run into is this might show more than what the user normally thinks of as installed apps. Remember apps can be in all kinds of places. Also this assumes you mean things bundled as .app bundles. (You do kind of need to ask yourself what an app is. Using a .app bundle is not a requirement for a GUI even though it certainly is the main way.

0

精彩评论

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