473,395 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Embedd Console in C# with System.Windows.Forms

mh
Hi everybod

who knows the *.dll to embedd the command prompt into C#, what i want to do, is make a graphical command prompt based on System.Windows.Forms

Thanks for helping
Nov 16 '05 #1
6 2213
TMK, not sure you can that. You can, however, simulate one with a Textbox
or richtext box and doing an input loop.

--
William Stacey, MVP

"mh" <an*******@discussions.microsoft.com> wrote in message
news:AC**********************************@microsof t.com...
Hi everybody

who knows the *.dll to embedd the command prompt into C#, what i want to do, is make a graphical command prompt based on System.Windows.Forms;
Thanks for helping


Nov 16 '05 #2
Hi,

Can you achieve this by changing input and output (SetIn/SetOut) of the
Console class?

Happy coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #3
mh
the problem isn't the graphical programming, i need a dll or something where i can geht the streams of the command prompt....
Nov 16 '05 #4
There is no such DLL, you have to redirect stdin/stdout from the command
shell started by calling System.Diagnostics.Process.Start, to your own
Winforms application.

Willy.
"mh" <an*******@discussions.microsoft.com> wrote in message
news:C8**********************************@microsof t.com...
the problem isn't the graphical programming, i need a dll or something
where i can geht the streams of the command prompt....

Nov 16 '05 #5
Here is something that did what you wanted. Not in c#, but you should be
able to port.
http://www.codeproject.com/dialog/quickwin.asp

--
William Stacey, MVP

"mh" <an*******@discussions.microsoft.com> wrote in message
news:C8**********************************@microsof t.com...
the problem isn't the graphical programming, i need a dll or something

where i can geht the streams of the command prompt....

Nov 16 '05 #6
Hi.

There is a better way to go about doing this. I've done this by creating a
new process and redirecting the standard input, output and error using
stream readers and writers. Then throw in a text box and write some handling
code to use the textbox for the prompt's i/o.

I think I found an exmaple of this on codeproject.com or something like that
and I got something similar to the code below from someone on there so I
don't take credit for this:
//----snip----------
private void handler() {
Process myProcess = new Process();
string output;

myProcess.StartInfo.FileName = "cmd.exe";
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.CreateNoWindow = true;
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.StartInfo.RedirectStandardOutput = true;;
myProcess.StartInfo.RedirectStandardError = true;
myProcess.Start();
StreamWriter incoming = myProcess.StandardInput;
incoming.AutoFlush = true;
StreamReader outgoing = myProcess.StandardOutput;
StreamReader error = myProcess.StandardError;

incoming.Write("dir c:\\windows\\system32\\*.com" +
System.Environment.NewLine);
incoming.Write("exit" + System.Environment.NewLine);

output = outgoing.ReadToEnd();

if( !myProcess.HasExited )
myProcess.Kill();

textBox1.Text = output;

incoming.Close();
outgoing.Close();
error.Close();
myProcess.Close();

textBox1.Select(0,0);
}
//----snip----------

When done properly, this will yield something like:
http://jinx.psyjnir.net/images/cnsl.png

Note that this code will not allow for real time interraction with the
prompt. It is up to you to find an elegant way to implement that. Anyway, I
hope this helps you out some.

Ben
Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mullin Yu | last post by:
But, I want is that I can have a Main app that will start a new process or kill one particular or all process. The process will open a console exe. But, I don't want the user to close the console...
1
by: Nuno Magalhaes | last post by:
How do I embedd an ocx control in a windows form in C#? Does it inherit from Microsoft.Windows.Forms.Form? Thanks for any response to this newbie question, Nuno Magalhaes.
8
by: Alison | last post by:
Hi, Al I am trying to design a user interface which provides both menus and toolbars for some users to click on whatever they want to do, at the same time, I would like to have a console window...
3
by: Siv | last post by:
Hi, A little while ago I wrote a small program that allowed the user to view products from a database. The database holds the details of the products which can be viewed via a form and...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.