在处理exe文件时隐藏表单并在关闭应用程序后显示表单 [英] Hide the form during processing an exe file and show form after close the application

查看:104
本文介绍了在处理exe文件时隐藏表单并在关闭应用程序后显示表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我,我是编程的初学者,我需要知道如何做到这一点(如果你对我的解释很糟糕,对不起我的英语)



Process.Start(My.exe)时隐藏表单;关闭应用程序后重新显示



Please kindly help me, Im a beginner to programming and i need to know how to do this (sorry about my English if you got sucks with my explanation)

Hide form when Process.Start(My.exe); and re show after close the Application

private void simpleButton2_Click(object sender, EventArgs e)
{
    Process.Start("My.exe");
}





i需要在我的应用程序目录中运行一个应用程序,当开始处理exe文件时我需要隐藏运行My.exe时的表单,关闭后显示My.exe



i need to run an application where in my application directory, when start to process the exe file i need to hide the form during run the My.exe, and show after close My.exe

推荐答案

你可以从应用程序启动路径重启你的exe如下所示

You can restart you exe from application start up path like below
ProcessStartInfo Info = new ProcessStartInfo();
      Info.Arguments = "/C \"" + Application.StartupPath + "\\AppRestart.exe" + "\"";
      Info.WindowStyle = ProcessWindowStyle.Normal;
      Info.CreateNoWindow = false;
      Info.FileName = "cmd.exe";
      Process.Start(Info);
      Environment.Exit(0);







显示和隐藏表格的代码




Code for show and hide the form

Form1 obj=new Form1();



显示


Show

obj.show();



隐藏


Hide

obj.hide();





请在任何地方显示和隐藏代码。



希望这有帮助



Please put show and hide code wherever you want.

Hope this helps


您可以等待使用<关闭进程code> process.WaitForExit() function。

查看示例:

You can wait for a process to close using process.WaitForExit() function.
See a sample example:
private void button1_Click(object sender, EventArgs e)
{
    Process proc = new Process();
    proc.StartInfo.FileName = "notepad";
    proc.Start(); //Starts the process
    this.Hide(); //Hides the form
    proc.WaitForExit(); //Wait until process is exited
    this.Show(); //Shows the form
}







- Amit


这篇关于在处理exe文件时隐藏表单并在关闭应用程序后显示表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆