Running an Exe process then hidding?

  • Thread starter Thread starter news.microsoft.com
  • Start date Start date
N

news.microsoft.com

I need to find a way to run an external exe (using the process class I
assume) and hide. When the process is closed I want my application to
reappear.

For example, press a button on form1, run notepad and hide form1. Close
notepad and form1 reappears.

Any ideas?

Thanks.
 
try something like this for a no-brainer solution

private void button1_Click(object sender, System.EventArgs e)
{
Process p = Process.Start("notepad.exe");
this.Visible = false;
p.WaitForExit();
this.Visible = true;
}

;-)
 
hi
yes .. it could be done through the proccess class and here is a general
idea; you will use the process of the System.Diagnostic namespace. Start
the notepad, hide you process, form one, pass a handler (IntP) of your
process to the other new one notepad (you do that through API calls). Once
done working with process two, you will do another API call (using the
handler that you hold) to reshow your other process.
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC
 
Hi,

I believe the following is what you are after

private void button1_Click(object sender, System.EventArgs e)
{
Process p = Process.Start("Notepad.exe");
this.Hide();
p.WaitForExit();
this.Show();

}

Just create an application with a form, add a button and paste the code for
the click handler.
 
if you want to simply minimize the application instead literally hiding all
it's forms use something like this:

private void button1_Click(object sender, System.EventArgs e)
{
Process p = Process.Start("notepad.exe");
this.Owner.WindowState = FormWindowState.Minimized;
p.WaitForExit();
this.Owner.WindowState = FormWindowState.Normal;
}

and make sure that when you open the form that will start the external
process that you assign that form's owner

the owner must be the application's main Form

ex:

Form2 f2 = new Form2();
f2.Owner = this;
f2.Show();
 
Back
Top