0

在 VB6 中创建进程时(与问题相关:),我使用以下结构:

Private Type STARTUPINFO
      cb As Long
      lpReserved As String
      lpDesktop As String
      lpTitle As String
      dwX As Long
      dwY As Long
      dwXSize As Long
      dwYSize As Long
      dwXCountChars As Long
      dwYCountChars As Long
      dwFillAttribute As Long
      dwFlags As Long
      wShowWindow As Integer
      cbReserved2 As Integer
      lpReserved2 As Long
      hStdInput As Long
      hStdOutput As Long
      hStdError As Long
   End Type

在我开始我的进程之前,为了让我的 VB6 应用程序读取我的托管进程的输出,STARTUPINFO.hStdOutput 需要发生什么?

谢谢!!

4

3 回答 3

5

跟进OP 提出的另一个问题,我发布了另一种方法来执行命令并获取标准输出:

' References: "Windows Script Host Shell Object Model" '

Public Declare Sub Sleep Lib "kernel32" Alias "Sleep" ( _
  ByVal dwMilliseconds As Long)

Function ExecuteCommand(cmd As String, ExpectedResult as Long) As String
  Dim shell As New IWshRuntimeLibrary.WshShell
  Dim exec As IWshRuntimeLibrary.WshExec

  Set exec = shell.Exec(cmd)
  While exec.Status = 0
     Sleep 100
  Wend

  If exec.ExitCode = ExpectedResult Then
    ExecuteCommand = exec.StdOut.ReadAll
  Else
    ExecuteCommand = vbNullString     ' or whatever '
  End
End Function
于 2009-02-21T16:38:18.557 回答
2

微软在这里举了一个例子来说明如何做到这一点。

于 2009-02-20T21:25:56.067 回答
0

AttachConsole(ATTACH_PARENT_PROCESS)

于 2009-02-20T21:42:34.590 回答