Console Capture

Squirm
12-17-2003, 09:15 AM
I've seen a fair few posts regarding this recently, so I knocked up a simple class which will launch an application and capture any console output it generates.

Use like so:

Dim WithEvents conApp As ConsoleCapture

Private Sub conApp_ReadProcess(readData As String)
txtOutput.Text = txtOutput.Text & readData
End Sub

Private Sub cmdRun_Click()
Set conApp = New ConsoleCapture
txtOutput.Text = ""
conApp.RunProcess "netstat"
End Sub

Private Sub cmdStop_Click()
conApp.Cancel
End Sub

Enjoy.

You may be interested in the Latest Version available below

Squirm
02-18-2004, 07:04 PM
I've made a very minor modification to this code, allowing you to pass a startup directory when you launch the process. Also included in the attachment is an example project which aims to emulate the main features of the basic Windows Command Prompt.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum