[英]Is there an equivalent of Mac OS X “open” command that can be called from C++/Objective-C code?
[英]C header for Mac OS X open Command or equivalent
我已经读过这些:
我正在尝试从打开命令中获取PID。 我们有一个内部的多平台C ++库,例如(过于简化):
pid = launch(char* command)
// Many other parameters and variations (sync/async,timeout,stdout,stderr,stdin )
但是,在OS X上,库用户通常使用以下命令:
Open myExe myArgs -F
它似乎:
我非常欢迎任何解决方案:
回到写我的解决方法的答案,我不喜欢它,因为我确实需要使用一些可可粉,但是它可以工作...
我已经获得了所需的“前景”行为,并使用以下代码获得了Pid:
NSString * arg1 = @"--my_arg";
NSString * arg2 = @"arg_value";
NSArray * myArray2 = [NSArray arrayWithObjects:arg1,arg2,nil];
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
[dict setObject:myArray2 forKey:NSWorkspaceLaunchConfigurationArguments];
bURL = [NSURL fileURLWithPath:@"/path/to/appli.app"];
NSRunningApplication * inst = [ws launchApplicationAtURL:bURL options:NSWorkspaceLaunchNewInstance configuration:dict error:nil];
pid_t pid = [inst processIdentifier];
在Xcode中,可以在我的file.mm中使用上面的代码,其签名在我的file.h中声明。 Xcode将自动管理可可粉。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.