|
Hi,
is it still not working when you have BOTH CancelRead calls present?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Nope it's still not working. The application still gets executed but it stops displaying the output after running the first app.
|
|
|
|
|
Hi,
neoflame wrote: this.pro_ShellApp.EnableRaisingEvents = true;
just noticed a possible confusion between pro_ShellApp and pro_App.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Sorry, that's just because in my project it's called pro_ShellApp but I took out the "Shell" part when I copied it here because I'm not really too sure if a console app can be called a shell app and I din't want to look too stupid :P
|
|
|
|
|
You'd better show real code, there must be a small mistake somewhere, and without the actual code people can't help you locate it.
Anyway, the below code works for me:
public void log(string s) {
lb.Items.Add(s);
lb.TopIndex=lb.Items.Count-1;
}
private void button1_Click(object sender, EventArgs e) {
p=new Process();
p.EnableRaisingEvents = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.Domain = "";
p.StartInfo.ErrorDialog = true;
p.StartInfo.LoadUserProfile = false;
p.StartInfo.Password = null;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.StandardErrorEncoding = null;
p.StartInfo.StandardOutputEncoding = null;
p.StartInfo.UserName = "";
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = "ipconfig";
p.SynchronizingObject = this;
p.Exited+=p_Exited;
p.ErrorDataReceived+=p_ErrorDataReceived;
p.OutputDataReceived+=p_OutputDataReceived;
p.Start();
p.BeginOutputReadLine();
p.BeginErrorReadLine();
}
private void p_OutputDataReceived(object sender, System.Diagnostics.DataReceivedEventArgs e) {
if (!String.IsNullOrEmpty(e.Data)) log("OUT: "+e.Data);
}
private void p_ErrorDataReceived(object sender, System.Diagnostics.DataReceivedEventArgs e) {
if (!String.IsNullOrEmpty(e.Data)) log("ERR: "+e.Data);
}
private void p_Exited(object sender, EventArgs e) {
log("END: Application Finished");
p.CancelOutputRead();
p.CancelErrorRead();
}
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thank you, that code worked perfectly I still don't know why mine wasn't working but I guess it doesn't matter now. The only thing I can't seem to get working is sending arguments to the executable. I have a text box called txt_Args and I've added p.StartInfo.Arguments = txt_Args.Text; just after where you set the FileName but it doesn't seem to work as I was expecting. I have a console app (not one that I made) that outputs help when you pass -h to it. I tried setting the path to that app and typing "-h" into the arguments field but it didn't display the help text. Yet if I open command prompt and type "theapp.exe -h" it displays the error text fine.
|
|
|
|
|
Hi,
when you add p.StartInfo.Arguments = "-all"; to my test code, it will show more output. Works fine for me.
IMO you need to take better care of small details, can't tell you exactly where though.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
What is Shortest way to move cursor to next column in DataGridView on ENTER press in C#.Net?
|
|
|
|
|
Convert it to a TAB key
I are troll
|
|
|
|
|
Hello Experts....
I am displaying my crystal report by coding on print button.now i want print it without using crystal report design print option i.e.by coding.....Is there any code for same.
Please help me.
|
|
|
|
|
Use Google
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
Hi,
I draw a Ball in a panel and I want it to move towards the position of the mouse that was clicked.I want to use a thread for the ball's path.so anybody can introduce any source or help?not that I did'nt try,I did (alot).but result was'nt what I wanted!
Thanks
|
|
|
|
|
|
I want to add SP2 of Window-XP as prerequisite in my Window application Setup. How can I do this?
Thanks in advance.
|
|
|
|
|
What kind of setup are you using? NSIS? MSI? other?
|
|
|
|
|
|
Hello friends,
Nice to be in CodeProject again! Can somebody tell me what exactly will be the piece of code for killing an active process? ex. notepad.exe.
Cheers,
Rajdeep.NET
|
|
|
|
|
Why don't you google? Or read the documentation?
जय हिंद
|
|
|
|
|
He never has in the past, why break a losing streak.....
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
Computafreak wrote: It's not Start()
There are five more overloads of Start. Which one is it then?
जय हिंद
|
|
|
|
|
try the pre-Vista way: Start("shutdown");
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
The one which sends your social security number, credit card number, name, address, birthdate, next of kin, and other such goodies which I WILL PROBABLY NOT USE TO STEAL YOUR IDENTITY to me
|
|
|
|
|
I need to make a little video elaboration run time.
I already founded many examples about avicap32.dll, but all of them using this dll for saving a file on the HD. I don't wont save a file, I need grab a frame and store it in a array o similar, for manage it later.
Sorry for my poor english, thanks for your anwers.
|
|
|
|
|
You can use a byte array to save any binary files in memory.
If you are dealing with an System.Drawing.Image object I suggest you serialize it into a memory stream,get memory stream buffer and let the memory stream go.
<br />
byte[] myImage;<br />
using(var ms=new MemoryStream())<br />
{<br />
var bf=new BinaryFormatter();<br />
bf.Serialize(ms,theImage);<br />
myImage=ms.GetBuffer();<br />
ms.Close();<br />
}<br />
You can use a BinaryFormatter again to deserialize myImage into an Image object.
<br />
Image theImage;<br />
using(var ms=new MemoryStream(myImage))<br />
{<br />
var bf=new BinaryFormatter();<br />
theImage=(Image)bf.Deserialize(ms);<br />
ms.Close();<br />
}<br />
Note : System.Draw.Image is serializable so we can serialize and deserialize it .To use the same method on nonserializable objects there should be a way to write content of the image into a memory stream.
|
|
|
|