1. 程式人生 > >c++建立程序執行檔案

c++建立程序執行檔案

// 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;
}