ホームページ  >  記事  >  バックエンド開発  >  C# でプロセスを開始する 3 つの方法

C# でプロセスを開始する 3 つの方法

黄舟
黄舟オリジナル
2016-12-21 14:42:431803ブラウズ
  1. 子プロセスの終了を待たずに子プロセスを開始 view plaincopy to ClipboardPRint?
    · · · · · · · 10 · · · · · · 20 · · · · · 30 ·・・・・・・40・・・50・・・60・・・70・・・80・・・・・・90・・・100・・・110・・・120・・・130・・・140・・・···150
    private void simpleRun_Click(object sender, System.EventArgs e)
    { System.Diagnostics.Process.Start(@"C:listfiles.bat")
    }
    private void simpleRun_Click(object sender, System. EventArgs e)
    { System .Diagnostics.Process.Start(@"C:listfiles.bat");
    }


    2. サブプロセスを開始し、サブプロセスが終了するのを待ち、出力ビューをクリップボードプリントにプレーンコピーしますか?
    private void runSyncAndGetResults_Click(object sender, System .EventArgs e)
    {
    System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(@"C:listfiles.bat");
    psi.RedirectStandardOutput = true; WindowStyle = System.Diagnostics.ProcessWindowSt yle.Hidden ;
    psi.UseShellExecute = false;
    System.Diagnostics.Process listFiles;
    System.IO.StreamReader = listFiles;標準出力;
    ListFiles.WaitForExit(2000);
    }
    private void runSyncAndGetResults_Click(object sender, System.EventArgs e)
    {
    System .Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(@"C:listfiles.bat ");
    psi.RedirectStandardOutput = true;
    psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
    psi.UseShellExecute = false;
    System.Diagnostics.Process listFiles;
    listFiles = System.Diagnostics.Process.Start(psi );
    System.IO.StreamReader myOutput = listFiles.StandardOutput;
    listFiles.WaitForExit(2000);
    if (listFiles.HasExited) R {
    文字列出力 = myoutput.readtoend ();
    this.ProcessResults.text = 出力;
    } }3. リント?・・・・・・・・・・・・110・・・・・・・・120・・・・130・・・・140・・・・150
    private void launchURL_Click(オブジェクト送信者, システム.EventArgs e)
    {
    string targetURL = @http://www.duncanmackenzie .net;
    System.Diagnostics.Process.Start(targetURL)




    上記はプロセスを開始する 3 つの方法ですその他の関連コンテンツについては、PHP 中国語 Web サイト (www.php.cn) に注目してください。



声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。