【发布时间】:2010-07-30 17:56:15
【问题描述】:
是否有 Coca/obj-C API 调用来模拟 Finder 中的“连接到服务器”操作?使用 Automater 是可能的,所以 Finder 似乎在某个地方有一个钩子。
【问题讨论】:
标签: objective-c cocoa macos finder
是否有 Coca/obj-C API 调用来模拟 Finder 中的“连接到服务器”操作?使用 Automater 是可能的,所以 Finder 似乎在某个地方有一个钩子。
【问题讨论】:
标签: objective-c cocoa macos finder
原来有一个名为 FSMountServerVolumeSync 的旧 Carbon 函数(找不到 Cocoa 等效函数)可以满足我的要求。您可以提供和smb:// URL 和登录凭据。
OSStatus FSMountServerVolumeSync (
CFURLRef url,
CFURLRef mountDir,
CFStringRef user,
CFStringRef password,
FSVolumeRefNum *mountedVolumeRefNum,
OptionBits flags
);
【讨论】:
一个简单的方法是运行一些applescript 代码。我会告诉你2个选择。第一个是从 applescript 显示 Finder 窗口的标准方式。
NSString* cmd = @"choose URL";
生成的窗口是简单的,所以你可以用这个命令打开 Finder 的窗口...
NSString* cmd = @"tell application \"Finder\" to activate\ndelay 0.2\ntell application \"System Events\" to keystroke \"k\" using command down";
选择任一“cmd”字符串后,您可以使用此命令执行该 AppleScript 代码...
NSAppleScript* theScript = [[NSAppleScript alloc] initWithSource:cmd];
[theScript executeAndReturnError:nil];
[theScript release];
【讨论】:
这可能不是最好的方式,但你不能只使用mount吗?
【讨论】:
smb://)?我很确定mount 仅适用于本地设备。