woj*_*uch 2 c# macos mono objective-c monomac
我目前正在使用Mono在C#中编写Mac OSX应用程序.我想要做的是确定程序运行的OSX的版本.
我找到了NSAppKitVersionNumber适合我需要的常数.
但是,我不知道如何访问它...
我相信这是可能的,因此您的任何帮助都将受到高度赞赏!
像这样的东西:
[DllImport("/System/Library/Frameworks/CoreServices.framework/CoreServices")]
internal static extern short Gestalt(int selector, ref int response);
static string m_OSInfoString = null;
static void InitOSInfoString()
{
//const int gestaltSystemVersion = 0x73797376;
const int gestaltSystemVersionMajor = 0x73797331;
const int gestaltSystemVersionMinor = 0x73797332;
const int gestaltSystemVersionBugFix = 0x73797333;
int major = 0;
int minor = 0;
int bugFix = 0;
Gestalt(gestaltSystemVersionMajor, ref major);
Gestalt(gestaltSystemVersionMinor, ref minor);
Gestalt(gestaltSystemVersionBugFix, ref bugFix);
if (major == 10 && minor == 5)
RunningOnLeopard = true;
else
{
RunningOnLeopard = false;
if (major == 10 && minor == 7)
RunningOnLion = true;
}
m_OSInfoString = string.Format("Mac OS X/{0}.{1}.{2}", major, minor, bugFix);
}
Run Code Online (Sandbox Code Playgroud)