如何在mac os x上获取默认邮件客户端版本?

时间:2021-03-27 00:24:57

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).

我是新来的。我在mac os x上搜索了默认邮件客户端信息。我在这里找到了一些帮助如何使用applescript获取默认邮件客户端?但我没有得到我想要的所有信息。我有默认的邮件客户端名称,但无法得到我在Mail.app的“关于邮件”部分(启动时)中看到的版本。

1 个解决方案

#1


5  

LaunchServices is the OS X API that contains info about the user's preferred applications.

LaunchServices是OS X API,包含有关用户首选应用程序的信息。

The LSGetApplicationForURL() function will return the data you seek. Here's a short example of its use:

LSGetApplicationForURL()函数将返回您搜索的数据。以下是其使用的简短示例:

#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.

在我的系统上,打印/Applications/Mail.app。如果您想了解有关返回项的更多信息,可以在mailAppURL上使用LSCopyItemInfoForURL()函数。

#1


5  

LaunchServices is the OS X API that contains info about the user's preferred applications.

LaunchServices是OS X API,包含有关用户首选应用程序的信息。

The LSGetApplicationForURL() function will return the data you seek. Here's a short example of its use:

LSGetApplicationForURL()函数将返回您搜索的数据。以下是其使用的简短示例:

#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.

在我的系统上,打印/Applications/Mail.app。如果您想了解有关返回项的更多信息,可以在mailAppURL上使用LSCopyItemInfoForURL()函数。