问题描述
我想从我的 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.
提前致谢,俄罗斯
推荐答案
如果你像这样使用 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++ 中执行另一个程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!