Click here to Skip to main content
13,351,156 members (25,129 online)
Click here to Skip to main content
Articles » Languages » C# » PInvoke » Downloads

Stats

139.1K views
3.6K downloads
199 bookmarked
Posted 2 Jul 2007

Window Tray Minimizer

, 26 Oct 2007
An article showing how to minimize any Window to the system tray
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Threading;

namespace Tray_minimizer
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Mutex mt = null;
            try
            {
                mt = Mutex.OpenExisting("Tray minimizer");
            }
            catch (WaitHandleCannotBeOpenedException)
            {
                
            }
            if (mt == null)
            {
                mt = new Mutex(true, "Tray minimizer");
                Application.Run(new Form1());
                GC.KeepAlive(mt);
                mt.ReleaseMutex();
            }
            else
            {
                mt.Close();
                MessageBox.Show("Application already running");
                Application.Exit();
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Giorgi Dalakishvili
Software Developer
Georgia Georgia
No Biography provided

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.180111.1 | Last Updated 26 Oct 2007
Article Copyright 2007 by Giorgi Dalakishvili
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid