How do I know if I should Application.Quit()?

  • Thread starter Thread starter Jim H
  • Start date Start date
J

Jim H

I have an app that connects to Outlook and syncs up some contacts form a
Paradox database. How do I know if I should call MyOutlookAppObject.Quit()?
If I call quit from my app while I already have Outlook up and running it
will close Outlook down. If I don't call it and I didn't have outlook
already running it sometimes seems to leave a process running with no UI.

How do I do this correctly?

Thanks,
Jim
 
There might be a better solution, but you could check to see if Outlook
is already running before you instantiate your MyOutlookAppObject. Like
this:

if (System.Diagnostics.Process.GetProcessesByName("OUTLOOK").Length > 0)
callQuit = false; // don't call Quit method
else
callQuit = true; // call Quit method

Erik
 
Hi Jim,

Thanks for posting in this group.
Based on my understanding, you want to determine if there is any outlook
running instance in system.
This can be done through Process.GetProcessesByName method.
GetProcessesByName is helpful for getting and manipulating all the
processes that are associated with the same executable file. For example,
you can pass an executable file name as the processName parameter, in order
to shut down all the running instances of that executable file.

Note: The process name is a friendly name for the process, such as Outlook,
that does not include the .exe extension or the path.

For more information, please refer to the link below:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemdiagnosticsprocessclassgetprocessestopic2.asp

Have nice day!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top