macos - 如何在cocoa中访问finder侧边栏共享​​内容

标签 macos cocoa shared-libraries finder

我想访问mac中finder左侧边栏的共享内容,以便获得连接到同一网络的系统列表。我可以访问喜爱的内容,但无法成功访问。

我正在使用此代码访问查找器最喜欢的内容。

UInt32 seed;
LSSharedFileListRef sflRef = LSSharedFileListCreate(NULL,
                                                    kLSSharedFileListFavoriteItems,
                                                    NULL);
CFArrayRef items = LSSharedFileListCopySnapshot( sflRef, &seed );
for( size_t i = 0; i < CFArrayGetCount(items); i++ )
{
    LSSharedFileListItemRef item = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(items, i);
    if( !item )
        continue;
    CFURLRef outURL = NULL;
    LSSharedFileListItemResolve( item, kLSSharedFileListNoUserInteraction, (CFURLRef*) &outURL, NULL );
    if( !outURL )
        continue;
    //The actual path string of the item
    CFStringRef itemPath = CFURLCopyFileSystemPath(outURL,kCFURLPOSIXPathStyle);
    // TODO: Do whatever you want to do with your path here!!!!
    CFRelease(outURL);
    CFRelease(itemPath);
}
CFRelease(items);
CFRelease(sflRef);


Since i want to access systems available in shared network i change the key according to the key in the header file 

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.fram‌​ework/Headers/LSSharedFileList.h

But i get nothing for shared content.

Can anyone help me for accessing this.
Thanks for your time to help me in advance.

最佳答案

您可以使用kLSSharedFileListRecentServerItems来获取最近连接的网络卷。

关于macos - 如何在cocoa中访问finder侧边栏共享​​内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17963165/

相关文章:

ios - 在 Core Data 中存储 NSURL 的正确方法是什么?

c++ - 如何使用 dlopen 检查共享库是否加载成功或未加载?

c++ - 为什么使用 clang 的 2 阶段命令行构建不会生成 dSYM 目录?

c - 下载 Rails - C 无法编译

objective-c - 以编程方式唤醒 OSX 上的显示

objective-c - 使用二进制图像数据更新 CakePHP Web 服务

objective-c - 界面生成器和 Cocoa : wiring up behind an App Controller class

java - 使用库时出现 ClassNotFoundException 异常

angular - 如何创建angular2库项目

macos - 苹果菜单栏的高度