- The Process class in the System.Diagnostics name space
- // Static Start with no reference to Process Object
Process.Start( "Notepad");
// Search for the Notepad process just created
Process[] processArray = Process.GetProcessesByName("notepad");
if (processArray[0].ProcessName == "notepad" )
Console.WriteLine("Notepad started ");
else
Console.WriteLine( "Notepad either reused or not started");
// Static Start with reference to Process Object
Process calcApp;
calcApp = Process.Start("Calc" );
if (calcApp != null)
Console.WriteLine("Calc started ");
else
Console.WriteLine( "Calc either reused or not started");
// Static Start with reference to Process Object
Process IEApp = Process.Start("iexplore" );
if (IEApp != null)
Console.WriteLine("IE started ");
else
Console.WriteLine( "IE either reused or not started");
// Instance Start with StartInfo
Process wordApp = new Process();
wordApp.StartInfo.FileName = "winword";
bool wordStarted = wordApp.Start();
if (wordStarted)
Console.WriteLine("Word started ");
else
Console.WriteLine( "Word either reused or not started");
// Static Start with Document
Process IEApp2 = Process.Start("http://www.google.com" );
if (IEApp2 == null)
Console.WriteLine("Second instance of IE started ");
else
Console.WriteLine( "IE instance reused or not started");
// Instance Start with Document as StartInfo
Process IEApp3 = new Process();
IEApp3.StartInfo.FileName = "http://www.microsoft.com" ;
bool IEstarted = IEApp3.Start();
if (IEstarted)
Console.WriteLine(" IE instance started");
else
Console.WriteLine("IE instance either reused or not started" );
--
Happy day, happy life!
No comments:
Post a Comment