#include
#include
#include
using namespace std;
PROCESS_INFORMATION* _handle;
/* exec由绝对路径和参数构成 */
int Excute(string& exec)
{
STARTUPINFOA si;
PROCESS_INFORMATION* pi = new PROCESS_INFORMATION;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( pi, sizeof(PROCESS_INFORMATION) );
// Start the child process.
if( !CreateProcessA( NULL, // No module name (use command line)
(LPSTR)exec.c_str(), // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
(LPSTARTUPINFOA)&si, // Pointer to STARTUPINFO structure
pi ) // Pointer to PROCESS_INFORMATION structure
)
{
return 1;
}
_handle = pi;
return 0;
}
int main()
{
string exe = "C:\\Python27\\python.exe D:\\Projects\\Test\\test-set\\test-1\\test_1.py";
if(Excute(exe) != 0)
{
cout<
}
else
{
cout<
}
getchar();
return 0;
}