![]() |
1
5
将命令行应用程序设置为Winforms应用程序,但不要像通常那样在窗体执行时打开窗体。 |
![]() |
2
3
启动时可以按如下方式隐藏窗口:
http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/ea8b0fd5-a660-46f9-9dcb-d525cc22dcbd |
![]() |
3
0
下面是一个在活动连接上查询MAC的示例代码,这是一个控制台应用程序,不需要将其设置为Windows窗体。。。 public class TestARP { private StringBuilder sbRedirectedOutput = new StringBuilder(); public string OutputData { get { return this.sbRedirectedOutput.ToString(); } } // Asynchronous! public void Run() { System.Diagnostics.ProcessStartInfo ps = new System.Diagnostics.ProcessStartInfo(); ps.FileName = "arp"; ps.ErrorDialog = false; ps.Arguments = "-a"; ps.CreateNoWindow = true; // comment this out ps.UseShellExecute = false; // true ps.RedirectStandardOutput = true; // false ps.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; // comment this out using (System.Diagnostics.Process proc = new System.Diagnostics.Process()) { proc.StartInfo = ps; proc.Exited += new EventHandler(proc_Exited); proc.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_OutputDataReceived); proc.Start(); proc.WaitForExit(); proc.BeginOutputReadLine(); // Comment this out } } void proc_Exited(object sender, EventArgs e) { System.Diagnostics.Debug.WriteLine("proc_Exited: Process Ended"); } void proc_OutputDataReceived(object sender, System.Diagnostics.DataReceivedEventArgs e) { if (e.Data != null) this.sbRedirectedOutput.Append(e.Data + Environment.NewLine); } }
现在,请看
希望这有帮助, 汤姆。 |
![]() |
CalculusLover · 在本例中,fork()是如何工作的? 2 年前 |
![]() |
jjmerelo · 使用Proc::Async从绑定管道读取 6 年前 |
![]() |
jatinBatra · 编译后生成的二进制文件会发生什么情况[关闭] 6 年前 |
![]() |
Jacobo · 从Java调用具有输入和输出重定向的C可执行文件 6 年前 |
![]() |
Ran · 每当我尝试执行命令行提示符时,Unity就会阻塞 6 年前 |
![]() |
Hatshepsut · 使用命令行参数使用region调用子流程 6 年前 |