4
Answers

how to Minimize a process and then kill it

gavriel ankri

gavriel ankri

14y
3.7k
1
hello.  I am new in this forum and I hope you can help me.

I am trying to open an application,  minimize it  and then kill it when I click on a button.

I did it like this:

    Process newProcess = Process.Start("wmplayer.exe");
            newProcess.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;


and then kill it when i press a button:

            if (newProcess != null)
                newProcess.Kill();
          

everything ok except the Minimize.  the application start in full windows and I dont know how to Minimize it.
If I do like this its work for me:
   ProcessStartInfo newprocess = new  ProcessStartInfo("wmplayer.exe");
          newprocess.WindowStyle = ProcessWindowStyle.Minimized;

but then I cant kill the process.


I hope you can hep me
thank you








Answers (4)
0
Deborah Stoddard

Deborah Stoddard

NA 14 0 9y
Yes this is possible, for example here is how you can do that with a help of LINQ and this C# library that can read INI file:
var ini = new IniFile();
ini.Load("Sample.ini");

var listItems = from iniSec in ini.Sections
                from iniKey in iniSec.Keys
                select
                    new ListViewItem(
                        string.Format("KEY NAME: {0}, KEY VALUE: {1}",
                            iniKey.Name, iniKey.Value));

this.listView1.Items.AddRange(listItems.ToArray());