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).
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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;
}
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
.