如何在Mac OS X上获取默认的邮件客户端版本? [英] how to get default mail client version on mac os x?
问题描述
我是新来的.我已经搜索了有关Mac OS X上默认邮件客户端信息的信息. 我在这里找到了一些帮助 如何使用applescript获取默认邮件客户端? 但是我没有得到我想要的所有信息.我获得了默认的邮件客户端名称,但无法获得我在Mail.app的关于邮件"部分(启动时)中看到的版本.
I am new here. I have searched about default mail client information on mac os x. I found some help here How do I get the default mail client using applescript? But i did not got all the information i wanted.I got default mail client name but could not got its version that i see in "About Mail" section of Mail.app(when launched).
推荐答案
LaunchServices is the OS X API that contains info about the user's preferred applications.
The LSGetApplicationForURL()
function will return the data you seek. Here's a short example of its use:
#include <CoreFoundation/CoreFoundation.h>
#include <ApplicationServices/ApplicationServices.h>
int main(int argc, char *argv[])
{
CFURLRef mailURL = CFURLCreateWithString(kCFAllocatorDefault, CFSTR("mailto://"), NULL);
CFURLRef mailAppURL = NULL;
OSStatus ret = 0;
if((ret = LSGetApplicationForURL(mailURL, kLSRolesAll, NULL, &mailAppURL)) == 0)
{
CFStringRef path = CFURLCopyFileSystemPath(mailAppURL, kCFURLPOSIXPathStyle);
CFShow(path);
CFRelease(path);
CFRelease(mailAppURL);
}
else
{
fprintf(stderr, "LaunchServices error %d\n", ret);
}
CFRelease(mailURL);
return ret;
}
在我的系统上,显示/Applications/Mail.app
.如果您需要有关退回商品的更多信息,可以使用
On my system, that prints /Applications/Mail.app
. If you want more info about the returned item, you can use the LSCopyItemInfoForURL()
function on mailAppURL
.
这篇关于如何在Mac OS X上获取默认的邮件客户端版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!