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++ 中执行另一个程序
基础教程推荐
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 从 std::cin 读取密码 2021-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01