Execute another program in C++(在 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.
提前致谢,俄罗斯
推荐答案
如果你像这样使用 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++ 中执行另一个程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 C++ 中执行另一个程序


基础教程推荐
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 我有静态或动态 boost 库吗? 2021-01-01
- 常量变量在标题中不起作用 2021-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01