在Visual Basic 6中读取Shell程序的标准输出 [英] Shell process' standard output reading in Visual Basic 6

查看:112
本文介绍了在Visual Basic 6中读取Shell程序的标准输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,让我说我不是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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆