我正在使用以下代码来获取应用程序的路径。它适用于所有情况但前排不合格。获取应用程序的路径
CFStringRef cfStrAppShortName = NULL;
FSRef appRef;
CFURLRef cfAppUrlRef = NULL;
CFBundleRef cfAppBundleRef = NULL;
CFDictionaryRef cfAppDictRef = NULL;
CFStringRef cfStrAppBundleName = NULL;
OSErr osErr;
cfStrAppShortName = CFSTR(Front Row);
if(cfStrAppShortName != NULL)
{
osErr = LSFindApplicationForInfo(kLSUnknownCreator,NULL,cfStrAppShortName,&appRef,NULL);
if(osErr == noErr)
{
cfAppUrlRef = CFURLCreateFromFSRef (kCFAllocatorDefault, &appRef);
cfAppBundleRef = CFBundleCreate (kCFAllocatorDefault,cfAppUrlRef);
cfAppDictRef = CFBundleGetInfoDictionary (cfAppBundleRef);
cfStrAppBundleName = (CFStringRef)CFDictionaryGetValue (cfAppDictRef,kCFBundleNameKey);
}
我是从应用程序文件夹期待应用程序的路径,但它来源于/系统/ coreservices/..
出现这种情况的所有项目呈现/系统/库/ coreservices/..。
是否有任何它不应该看/ system/library/coreservices ..或任何更好的解决方案? 任何人都可以帮助我吗?
在此先感谢。
你有什么具体问题?它没有找到应用程序,还是它返回了你不期望的路径? – 2009-12-30 06:26:07
它的路径。 在System/Library/CoreServices/..中有一个FrontRow.app,它也存在于/ Applications/..路径中。 我期待/应用程序/前排,但它给了我系统/库/ CoreServices /前排 – MacGeek 2009-12-30 07:23:04