techie.ashish
February 13th, 2008, 06:40 AM
Hey all...
I'm trying to call an exe i.e (PING) with argument ("www.yahoo.com")
and want output in my textBox instead of console...
I manage to redirect output to my textBox and also manage to hide the console window but in synchronous way... i.e the output comes after ping get fully executed... I need the output in asynchronous way..The way it shows in console window(Line by Line)..
I know i've to use BeginOutputreadLine() but couldn't manage to write exact code..Can anyone help mr out..
Following is my code ..
Process^ myProcess = gcnew Process;
ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo;
myProcessStartInfo->FileName = "ping.exe";
myProcessStartInfo->Arguments = "www.yahoo.com";
myProcessStartInfo->UseShellExecute = false;
myProcessStartInfo->RedirectStandardOutput = true;
myProcessStartInfo->CreateNoWindow = true;
myProcess->StartInfo = myProcessStartInfo;
myProcess->Start();
StreamReader^ myStreamReader = myProcess->StandardOutput;
textBox1->Text = myStreamReader->ReadToEnd();
myProcess->Close();
I'm trying to call an exe i.e (PING) with argument ("www.yahoo.com")
and want output in my textBox instead of console...
I manage to redirect output to my textBox and also manage to hide the console window but in synchronous way... i.e the output comes after ping get fully executed... I need the output in asynchronous way..The way it shows in console window(Line by Line)..
I know i've to use BeginOutputreadLine() but couldn't manage to write exact code..Can anyone help mr out..
Following is my code ..
Process^ myProcess = gcnew Process;
ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo;
myProcessStartInfo->FileName = "ping.exe";
myProcessStartInfo->Arguments = "www.yahoo.com";
myProcessStartInfo->UseShellExecute = false;
myProcessStartInfo->RedirectStandardOutput = true;
myProcessStartInfo->CreateNoWindow = true;
myProcess->StartInfo = myProcessStartInfo;
myProcess->Start();
StreamReader^ myStreamReader = myProcess->StandardOutput;
textBox1->Text = myStreamReader->ReadToEnd();
myProcess->Close();