您的位置:首页 > 编程语言 > C语言/C++

c++创建进程执行文件

2017-07-21 10:47 309 查看
// ConsoleApplication3.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <iostream>
#include <string>
#include<windows.h>
#include<iostream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{

wstring szCmdLine = L"E:\\svn\\备份\\cefclient\\Release\\安装包\\科学阅读器 Setup.exe";
//wstring szCmdLine = L"C:\\Users\\Jin\\Documents\\Visual Studio 2013\\Projects\\Win32Project2\\Debug\\Win32Project2.exe";
STARTUPINFO si = { sizeof(si) };
PROCESS_INFORMATION pi;
si.wShowWindow = 1;
//si.dwFlags = STARTF_USESHOWWINDOW;
BOOL ret = ::CreateProcessW(
NULL,
&szCmdLine[0],
NULL,
NULL,
0,
0,
NULL,
NULL,
&si,
&pi);
if(ret)
{
::CloseHandle(pi.hProcess);
::CloseHandle(pi.hThread);
std::cout<<"新进程的id:"<<pi.dwProcessId<<std::endl
<<"Thread id:"<<pi.dwThreadId<<std::endl;
}

return 0;

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: