qt环境下启动新进程
#include "dialog.h"
#include "ui_dialog.h"
#include <Windows.h>
#include "stdio.h"
using namespace std;
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
}
Dialog::~Dialog()
{
delete ui;
}
void Dialog::on_pushButton_clicked()
{
STARTUPINFO startup_info;
GetStartupInfo(&startup_info);
PROCESS_INFORMATION process_info;
startup_info.dwFlags=STARTF_USESHOWWINDOW;
startup_info.wShowWindow=SW_HIDE;
const TCHAR *ie= L"C:\\Program Files\\Internet Explorer\\iexplore.exe";
TCHAR cmd[100]= L"open http://www.baidu.com/";
if (!CreateProcess(ie,cmd,NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL,&startup_info,&process_info))
{
//cout<<"Create Process Error:"<<GetLastError()<<endl;
return;
}
//Sleep(5000);
//TerminateProcess(process_info.hProcess,0);
}