当前位置: 首页>>代码示例>>C#>>正文


C# System.Diagnostics.Process.CloseMainWindow方法代码示例

本文整理汇总了C#中System.Diagnostics.Process.CloseMainWindow方法的典型用法代码示例。如果您正苦于以下问题:C# System.Diagnostics.Process.CloseMainWindow方法的具体用法?C# System.Diagnostics.Process.CloseMainWindow怎么用?C# System.Diagnostics.Process.CloseMainWindow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Diagnostics.Process的用法示例。


在下文中一共展示了System.Diagnostics.Process.CloseMainWindow方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: runShellCommand

 internal static bool runShellCommand(string command) {
     System.Diagnostics.Process p = new System.Diagnostics.Process {
         StartInfo = new System.Diagnostics.ProcessStartInfo {
             WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden,
             FileName = "cmd.exe",
             Arguments = (@"CMD /C " + command)
         }
     };
     p.Start();
     p.WaitForExit(5000);
     if (p.HasExited == false) { //Check to see if the process is still running.
         if (p.Responding) {//Test to see if the process is hung up.
             p.CloseMainWindow();//Process was responding; close the main window.
             return false;
         } else {
             p.Kill(); //Process was not responding; force the process to close.
             return false;
         }
     }
     return true;
 }
开发者ID:ubuetake,项目名称:selenium-vba,代码行数:21,代码来源:Utils.cs

示例2: ExecProc

        /// <summary>
        /// Instantiate a new process to execute the application in the given path.
        /// This is used primary to install/uninstall individual keyboard msi builds.
        /// </summary>
        /// <param name="path">The path to the application to install</param>
        /// <param name="arg">Arguments to pass to the application</param>
        /// <param name="wait">Wait for the process to complete before returning.</param>
        private void ExecProc(string path, string arg, bool wait)
        {
            //create the process instance to execute the application.
            System.Diagnostics.Process proc = new System.Diagnostics.Process();
            proc.EnableRaisingEvents = true;
            proc.Exited += new EventHandler(proc_Exited);
            proc.StartInfo.FileName = path;
            proc.StartInfo.Arguments = arg;
            proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
            this.WindowState = FormWindowState.Minimized;
            proc.Start();

            //wait for the process to finish.
            if (wait == true)
            {
                proc.WaitForExit();
                if (proc.HasExited == false)
                    proc.CloseMainWindow();
            }
        }
开发者ID:amonmoce,项目名称:africakeyboards,代码行数:27,代码来源:MainForm.cs


注:本文中的System.Diagnostics.Process.CloseMainWindow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。