well, You cant simply do that. The developer of the program must provide GUI version of program. If you are developer, you have to write a code for GUI design...
khajvah
Junior Poster in Training
64 posts since Jan 2012
Reputation Points: 10
Solved Threads: 4
Infraction Points: 5
PhilliePhan
Central Scrutinizer
1,942 posts since Dec 2006
Reputation Points: 184
Solved Threads: 110
Some of this code is mine and some is not. It is an example of how to build a GUI for a console application. In this case, the application is md5sums.exe, which takes a file or folder name as an argument then calculates a checksum for the file, or all files in the folder. The controls on the form are
txtOutput - displays program output (stdout and stderr)
tstFile - for the user to enter a file or folder name
btnExecute - executes the command
Public Class Form1
Private WithEvents MyProcess As Process
Private Delegate Sub UpdateOutputDelegate(ByVal text As String)
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
MyProcess = New Process
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
MyProcess.Close()
End Sub
Private Sub btnExecute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExecute.Click
If My.Computer.FileSystem.FileExists(txtFile.Text) Or My.Computer.FileSystem.DirectoryExists(txtFile.Text) Then
With MyProcess.StartInfo
.FileName = "cmd.exe"
.Arguments = "/c d:\utils\md5sums.exe " & txtFile.Text
.UseShellExecute = False
.CreateNoWindow = True
.RedirectStandardInput = True
.RedirectStandardOutput = True
.RedirectStandardError = True
End With
MyProcess.Start()
MyProcess.BeginErrorReadLine() 'start async read on stderr
MyProcess.BeginOutputReadLine() 'start async read on stdout
Else
MsgBox("file or folder not found", vbOKOnly, txtFile.Text)
End If
End Sub
Private Sub MyProcess_ErrorDataReceived(ByVal sender As Object, ByVal e As System.Diagnostics.DataReceivedEventArgs) Handles MyProcess.ErrorDataReceived
'add stderr text to output display
UpdateOutput(vbCrLf & "Error: " & e.Data)
End Sub
Private Sub MyProcess_OutputDataReceived(ByVal sender As Object, ByVal e As System.Diagnostics.DataReceivedEventArgs) Handles MyProcess.OutputDataReceived
'add stdout text to output display
UpdateOutput(vbCrLf & e.Data)
End Sub
Private Sub UpdateOutput(ByVal text As String)
'add text to output display
If txtOutput.InvokeRequired Then
Dim myDelegate As New UpdateOutputDelegate(AddressOf UpdateOutput)
Me.Invoke(myDelegate, text)
Else
txtOutput.AppendText(text)
End If
End Sub
End Class
Code could be added to parse the text in txtOutput and extract the checksum. Comments on how to improve this code are always appreciated.
Reverend Jim
Posting Shark
1,161 posts since Aug 2010
Reputation Points: 253
Solved Threads: 158
What about in C++?
Then that's a question for the C++ forum.
Reverend Jim
Posting Shark
1,161 posts since Aug 2010
Reputation Points: 253
Solved Threads: 158