Windows编程 - 启动可执行(exe)程序 代码(C++)

启动可执行(exe)程序 代码(C++)

 

本文地址: http://blog.csdn.net/caroline_wendy

 

通过输入程序位置启动可执行(exe)程序, 使用windows的CreateProcess()函数, 即可.

示例是调用预先生产的可执行(exe)程序.

 

代码:

 

/*
 * main.cpp
 *
 *  Created on: 2014.06.08
 *      Author: Spike
 */

/*vs 2012*/

#include 
#include 

using namespace std;

bool startProcess (const std::string name_) 
{
	STARTUPINFO si; //参数设置
	memset(&si, 0, sizeof(STARTUPINFO));
	si.cb = sizeof(STARTUPINFO);
	si.dwFlags = STARTF_USESHOWWINDOW;
	si.wShowWindow = SW_SHOW;

	PROCESS_INFORMATION pi; //参数结束

	/*printf("Please enter the name of process to start:");
	std::string name;
	cin >> name;*/

	if (!CreateProcess(NULL, (LPSTR)name_.c_str(), NULL, NULL, FALSE, 0,NULL,NULL,&si,&pi)) {
		cout<<"Create Error!"<


注: Image.exe 是预先生产的可执行(exe)程序.

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(Mystra,Windows编程,启动,exe程序,C++)