【发布时间】:2014-07-06 07:54:02
【问题描述】:
通过像Code::Blocks这样的编译器编译,我尝试了以下,有点不起作用:
/*Running Firefox.exe*/
#include <stdio.h>
/*using c++*/
#include <iostream>
#include <stdlib.h>
using namespace std;
int main ()
{
int x;
cout << "Checking if processor is available..." << endl;
/*System used here*/
if (system(NULL)) puts ("Proceed");
else exit (1);
cout<< "Executing Firefox..." << endl;
/*Having some error here saying not recognized as internal or external command*/
x = system ("C:/Program Files (x86)/Mozilla Firefox/firefox.exe");
/*cout here*/
cout <<"The value returned was:" << x << endl;
return 0;
}
是不是因为 Firefox 不被识别为 windows 系统?如果是这样,我如何从代码中运行 Firefox 甚至 Internet Explorer?
【问题讨论】:
-
试试
system("\"C:/Program...\"");,即引用路径 -
如果你尝试
\\而不是/呢? -
完整路径的示例?路径文件目录与 / 但从我所指的示例中,这是一个计算器.exe,它使用 \ 作为其目录路径
-
Code::Blocks in not 编译器;它是一个 IDE。很可能您将它与 MinGW/GCC 一起使用。
-
是否可以在后台运行firefox而不执行它?