#include <iostream>
#include <string>
#include <Windows.h>
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<<GetLastError()<<endl;
}
else
{
cout<<"succeed"<<endl;
}
getchar();
return 0;
}
最后
以上就是勤恳芒果最近收集整理的关于CreateProcess函数调用python文件的全部内容,更多相关CreateProcess函数调用python文件内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复