Tray icon context
Наследование: System.Windows.Forms.ApplicationContext
Пример #1
0
 static void Main()
 {
     string appProcessName = Path.GetFileNameWithoutExtension(Application.ExecutablePath);
     Process[] RunningProcesses = Process.GetProcessesByName(appProcessName);
     if (RunningProcesses.Length <= 1) // just me, so run!
     {
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         try
         {
             NotifyIconApplicationContext applicationContext = new NotifyIconApplicationContext();
             Application.Run(applicationContext);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Program Terminated Unexpectedly", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Пример #2
0
        static void Main()
        {
            string appProcessName = Path.GetFileNameWithoutExtension(Application.ExecutablePath);

            Process[] RunningProcesses = Process.GetProcessesByName(appProcessName);
            if (RunningProcesses.Length <= 1) // just me, so run!
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                try
                {
                    NotifyIconApplicationContext applicationContext = new NotifyIconApplicationContext();
                    Application.Run(applicationContext);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Program Terminated Unexpectedly", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }