我想从我的 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++ 中执行另一个程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
读取输入文件,最快的方法?read input files, fastest way possible?(读取输入文件,最快的方法?)
在 C++ 中读取格式化输入的最简单方法?The easiest way to read formatted input in C++?(在 C++ 中读取格式化输入的最简单方法?)
从 .txt 文件读取到 C++ 中的二维数组Reading from .txt file into two dimensional array in c++(从 .txt 文件读取到 C++ 中的二维数组)
如何在 C++ 中模拟按键按下How to simulate a key press in C++(如何在 C++ 中模拟按键按下)
为什么在 cin.ignore() 之后没有 getline(cin, var) 读取Why doesn#39;t getline(cin, var) after cin.ignore() read the first character of the string?(为什么在 cin.ignore() 之后没有 getline(cin, var) 读取
scanf 格式输入的 cin 类比是什么?What is the cin analougus of scanf formatted input?(scanf 格式输入的 cin 类比是什么?)