c++使用ShellExecuteA执行python文件



所以我试图执行一个python文件(没有控制台)使用c++ shellapi.h ShellExecuteA,但它不会工作,返回值42,如果我做

int value = ShellExecuteA(nullptr,"open",path.c_str(),nullptr,nullptr, SW_HIDE );

和返回(错误2)如果我使用GetLastError();从errhandlingapi.h这是c++中的整个函数

void mainwindow::make_projectsave(){
ofstream ofFile(PATH + string("depozitdir\info.txt"));
string line;
for(int nr = 0;nr<scazator.size();nr++){
line = column1[nr] +"  "+ column2[nr] +"  "+ column3[nr] + "  "+ scazator[nr] +"  "+ column4[nr] + "n";
ofFile<<line;}

string dirname = std::string(namevector[2]);
string name = std::string(namevector[0]);
namevector.clear();
ofFile<< "=filename->" +name+"n";
ofFile<< "=dir->" +dirname+"n";
ofFile.close();
string path = PATH + "makesave.pyw";
ShellExecuteA(nullptr,"open",path.c_str(),nullptr,nullptr, SW_HIDE ); // doesnt work...

它的作用是它将一些信息存储到文件info.txt中,然后调用python文件(这不起作用),因此它生成一个excel文件。

要解决这个问题,让您想要执行的文件变为.py,而不是.pyw