在 Visual Basic 6 中读取 Shell 进程的标准输出 [英] Shell process' standard output reading in Visual Basic 6
问题描述
首先,我说我不是 Visual Basic 6 专家...
First, let me say that I'm not a Visual Basic 6 expert...
我的需要是:
- 从 VB6 客户端代码启动外部 .exe 文件
- 等待进程完成,并在执行过程中即时"读取来自其标准输出的消息(以便我可以将其打印在文本文件小部件或类似部件上).
我想知道在 VB6 中是否甚至可以做到这一点......在互联网上进行了长时间的搜索后,我没有想出任何东西.找到了很多关于如何使用 Shell
函数的例子,但它似乎迫使我在进程执行结束时一次性读取标准输出,但我想轮询进程以获取新鲜的"消息,因为它们可用.
I'm wondering if it is even possible to do that in VB6...after a long search on the Internet I didn't come up with anything. Found a lot of examples of how to use the Shell
function, but it seems to force me to read the stdout all at once when the process' execution is over, but I want to poll the process for "fresh" messages as they become available.
非常感谢任何代码片段/建议/参考.
Any code snippets/suggestions/references are really appreciated.
提前致谢!
推荐答案
使用 CreatePipe()
创建可以传递给 CreateProcess()
的匿名管道.然后,您可以根据需要从此管道读取数据(使用轮询或重叠/异步 I/O.
Use CreatePipe()
to create an anonymous pipe that you can pass to CreateProcess()
.
You can then read from this pipe as required (either using polling or overlapped/async I/O.
这应该给你足够的信息来找到一个很好的例子.
This should give you enough info to find a good example.
这篇关于在 Visual Basic 6 中读取 Shell 进程的标准输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!