Exemple #1
0
        public static void Main(string[] args)
        {
            lastHwnd = GetForegroundWindow();
            lastPid  = GetWindowProcessID(lastHwnd);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            bool isFirstInstance;

            // Please use a unique name for the mutex to prevent conflicts with other programs
            using (Mutex mtx = new Mutex(true, "TextFileXpander", out isFirstInstance)) {
                if (isFirstInstance)
                {
                    NotificationIcon notificationIcon = new NotificationIcon();
                    notificationIcon.notifyIcon.Visible = true;
                    Application.Run();
                    notificationIcon.notifyIcon.Dispose();
                }
                else
                {
                    // The application is already running
                    MessageBox.Show("The application is already running");
                }
            }             // releases the Mutex
        }
		public static void Main(string[] args)
		{
			lastHwnd = GetForegroundWindow();
			lastPid = GetWindowProcessID(lastHwnd);

			Application.EnableVisualStyles();
			Application.SetCompatibleTextRenderingDefault(false);

			bool isFirstInstance;
			// Please use a unique name for the mutex to prevent conflicts with other programs
			using (Mutex mtx = new Mutex(true, "TextFileXpander", out isFirstInstance)) {
				if (isFirstInstance) {
					NotificationIcon notificationIcon = new NotificationIcon();
					notificationIcon.notifyIcon.Visible = true;
					Application.Run();
					notificationIcon.notifyIcon.Dispose();
				}
				else {
					// The application is already running
					MessageBox.Show("The application is already running");
				}
			} // releases the Mutex
		}