在C ++中执行另一个程序 [英] Execute another program in C++

查看:180
本文介绍了在C ++中执行另一个程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的C ++程序远程执行另一个应用程序。到目前为止,我使用CreateProcess(...)函数,它的工作正常。

I want to remotely execute another application from my C++ program. So far I played along with the CreateProcess(...) function and it works just fine.

问题是,我需要其他程序的完整路径,我不知道它的目录。所以我想要的是,我只需要输入其他程序的名称,就像当你输入cmd或winword到运行...它打开相应的程序。

The problem however is that I need the full path of the other program but I do not know the directory of it. So what I want is that I just have to enter the name of the other program, like when you type "cmd" or "winword" into Run... it opens the corresponding programs.

提前感谢,
Russo

Thanks in advance, Russo

推荐答案

如果你像这样使用CreateProcess:

If you are using CreateProcess like this:

CreateProcessA( "winword.exe", .... );

那么不会使用PATH变量。您需要使用第二个参数:

then the PATH variable will not be used. You need to use the second parameter:

CreateProcessA( NULL, "winword.exe", .... );

请参阅http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx 了解详情。

这篇关于在C ++中执行另一个程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆