Check if outlook is already running
On May 28, 8:11 am, Yael wrote:
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
/// returnsRunning 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;
}
|