在Mac上用c++打开一个附加程序[XCode]
Open an additional program with c++ on Mac [XCode]
我想在XCode上用c++打开一个额外的程序。它是火狐。但如果我做
Shell Execute("file://localhost/Applications/Firefox.app");
出现错误'ShellExecute' was not declared in this scope
在另一个论坛中,有一条线索包括windows.h和shellapi.h
#include <shellapi.h>
#include <windows.h>
但这会导致其他错误
shellapi.h: No such file or directory
windows.h: No such file or directory
我该怎么办?我想在Mac上用XCode中的c++打开frefox?
尝试在终端中运行此程序以打开Firefox:
open -a Firefox http://www.ibm.com
如果这是你想要的,你需要像这样用system()
包装它:
#include <cstdlib>
#include <fstream>
#include <iostream>
int main()
{
std::system("open -a Firefox");
}
ShellExecute()
仅通过Windows API提供。您没有Windows系统。
您可以简单地使用(更便携的)system()
函数,或者在符合POSIX的系统上可用的exec()
函数之一。
我对chrome也做了同样的尝试,我不得不用引号设置它:
int main() {
system("open -a 'Google Chrome'");
return 0;
}
用撇号就行了!
相关文章:
- 我试图制作一个程序,要求用户输入问题和答案,但程序循环不正确
- 我写了一个C++程序来模拟Enigma机器.我没有得到输出
- 如何使用C++读取另一个程序中的源代码输出
- 3-3. 编写一个程序来计算每个不同单词在其输入中出现的次数
- 我的目标是编写一个程序来计算和存储字符串在字符数组中出现的位置
- 使用另一个程序调用正在运行的 C++ 程序中的函数
- 我正在尝试制作一个程序,在添加 n 天(整数)后告诉一个人什么是一天(例如星期一等)
- 编写一个程序,帮助Tudio将MIDI音符转换为名称和八度音阶
- 有没有办法在一个C++程序中同时使用 FFTW 和 cuFFTW?
- 一个C++程序,用于在输入位数时输出具有特定位数的 .txt 文件中的所有数字
- C++将结构复制到另一个程序的资源
- 我编写了一个程序来显示数组的内容,但它显示的是它的地址
- 我已经做了一个程序来使用队列链C++表显示学生姓名和身高,现在我想以我不知道如何显示的顺序显示它
- 我需要编写一个程序来读取一个文件,该文件将输出所有唯一的整数,如果已经看到整数,它将被关闭
- 仅在 boost::hash_combine 中运行一个程序期间保证确定性
- 如何制作一个程序,它使用特定单词加密和解密消息?
- 尝试创建一个程序来查找非二叉树的高度.最终得到一个很长的循环,没有答案
- 编写一个程序,提示用户输入一个整数,然后输出数字的单个数字和数字的总和
- 如何编写一个程序来打印特定基数的前N个数字
- 如何创建一个C++程序来读取字符串数组中的信息,然后将其排序到类中?