Check if outlook is already running

G

Guest

How can I check from C# code if outlook program is already running?
if not, I run outlook with:
System.Diagnostics.Process.Start("OUTLOOK.EXE");
 
P

pascal.groulx

How can I check from C# code if outlook program is already running?
if not, I run outlook with:
System.Diagnostics.Process.Start("OUTLOOK.EXE");

/// <summary>
/// Determines whether or not Outlook.exe is running on this
computer.
/// </summary>
/// <returns>Running or not</returns>
private bool IsRunning()
{
bool Result = false;

System.Diagnostics.Process[] aProcess =
System.Diagnostics.Process.GetProcesses();
for ( int ProcessIndex =0; ProcessIndex < aProcess.Length ;
ProcessIndex++)
{
if ( aProcess[ProcessIndex].ProcessName.ToUpper() == "OUTLOOK" )
{
Result = true;
break;
}
}

return Result;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top