标签:mystra windows编程 启动 exe程序 c++
本文地址: http://blog.csdn.net/caroline_wendy
通过输入程序位置启动可执行(exe)程序, 使用windows的CreateProcess()函数, 即可.
示例是调用预先生产的可执行(exe)程序.
代码:
/* * main.cpp * * Created on: 2014.06.08 * Author: Spike */ /*vs 2012*/ #include <iostream> #include <windows.h> 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!"<<endl; return false; } else { cout<<"Create Sucess!"<<endl; } return true; } int main() { const std::string name = "D:/Test/Image.exe"; if (!startProcess(name)) { cout << "Start Process Error!" << endl; } return 0; }
Windows编程 - 启动可执行(exe)程序 代码(C++),布布扣,bubuko.com
Windows编程 - 启动可执行(exe)程序 代码(C++)
标签:mystra windows编程 启动 exe程序 c++
原文地址:http://blog.csdn.net/caroline_wendy/article/details/29381131