# Re: 请问关于shell问题

Posted by Someone on February 08, 1999 at 08:21:33:

In Reply to: 请问关于shell问题 posted by kit on February 07, 1999 at 18:31:56:

: 请问如何可以得到,在用shell开启之程式(dos下的执行档)输出的文字
: 谢谢
Re :
我有一个笨方法，仅供参考，我是将输出转成一个文字档，首先宣告
Private Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" _
(ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Dim ShellID, ExitCode, hProcess As Long
Const PROCESS_QUERY_INFORMATION = &H400
Const STILL_ALIVE = &H103
'以上请参考cww网站上Shell相关详细说明
在事件中利用ShellID =Shell("command.com /c 加执行档后面再加>Output.txt,vbHide) '将它转到Output文字档
'然后呼叫API判断是否此程序已完毕
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, 0, ShellID)
Do
Call GetExitCodeProcess(hProcess, ExitCode)
Loop While ExitCode = STILL_ALIVE
Call CloseHandle(hProcess)
Open "Output.txt" For Input As #1
While Not EOF(1)
Line Input #1, OutputLine
.....
'后面就是开档的动作，应该会吧！
我再想一定有其他办法，也麻烦各位高手赐教顺便教教小弟 ：)

Follow Ups: