简体   繁体   English

如何在MFC中进行系统调用?

[英]How to do system call in MFC?

It is a really old MFC program which I have to use right now. 这是我现在必须使用的非常老的MFC程序。 Some calculation needs to be done and I already have a python script written for that, writing things again in c++ is too time consuming, so I made MFC output data in text file, then try to use system() to call python (as system("python XXX.py") ) and write the result back in another text file. 需要进行一些计算,并且我已经为此编写了一个python脚本,再次用c ++编写内容非常耗时,因此我在文本文件中制作了MFC输出数据,然后尝试使用system()来调用python(作为system("python XXX.py") ),然后将结果写回到另一个文本文件中。 But when the MFC program ran to that part, the command window popped up briefly but no text file was generated. 但是当MFC程序运行到该部分时,命令窗口会短暂弹出,但是没有生成文本文件。 I tested system("python XXX.py") in a separated c++ project and it worked fine, so it must be a MFC problem, I have googled and tried using _spawnl() , but it is not working. 我在一个单独的c ++项目中测试了system("python XXX.py") ,它工作正常,所以它一定是MFC问题,我已经在google上搜索并尝试使用_spawnl() ,但是它不起作用。 Needs help, thanks in advance. 需要帮助,在此先感谢。

No, it's not an MFC problem. 不,这不是MFC问题。 system() in both cases is the same C library function. 两种情况下的system()都是相同的C库函数。

However, note that XXX.py is a filename without path. 但是,请注意XXX.py是没有路径的文件名。 Your problem might simply be that the file isn't found. 您的问题可能仅仅是因为找不到该文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM