Solved

Low Impact System Tray Application

Posted on 2004-09-13
2
235 Views
Last Modified: 2010-04-15
Basically, I want the source of this program:
<a href="http://toolbar.google.com/gmail-helper/">Gmail Notifier</a>
I am recreating it, and just getting started, but I'm stuck already.
Here's my main:
[STAThread]
static void Main()
{
      Form1 mainForm = new Form1();                  
      Application.Run();
}
Here's my Form1 constructor:
public Form1()
{ }
Absolutely nothing has been done, but it's already using more memory than the Gmail Notifier. Four MB's more (Windows Task Manager says so). I opened Microsoft Spy++, clicked "Processes", and here's the specs.
Gmail Notifier: 10 threads
--Windows: All the threads but two show nothing. The other two:
----Number one: "" GoogleGmailNotifySysTray
----Number two: "MCI command handling window" #43
My Form: 3 threads
--No Windows
My question: Is there another way to have a program run in the system tray, without all the windows forms mess? I want this program to use very little resources. I am pretty sure that the Gmail Notifier is made with .NET, so, I know that there IS a way to do it using less resources. I don't need the windows forms at all: I plan to have the program read logins and passwords out of a local xml file, then login with those and if there's new mail, change the icon (just like Gmail Notifier). I am confidant that I know how to do that, so all I'm asking is the system tray question.
--------------------------------------------------------------------------------------------------------------
How do I get an icon in the system tray without a System.Windows.Forms.Form and NotifyIcon?
--------------------------------------------------------------------------------------------------------------
Thanks in advance,
-Chris
0
Comment
Question by:klexys
2 Comments
 
LVL 14

Assisted Solution

by:AvonWyss
AvonWyss earned 100 total points
ID: 12048171
What makes you think that Gmail Notifier is made with .NET? Note that all .NET apps have a quite large footprint if loaded into a separate process since they are running a complete CLR environment (including the whole garbage collector and jit compiler stuff). To see the really minimal footprint of a .NET app, create a console application that just waits for a keypress and remove all references to Windows.Forms, Windows.XML etc. You'll see that this app still needs quite some resources to start with.
0
 
LVL 10

Accepted Solution

by:
eternal_21 earned 400 total points
ID: 12049872
> How do I get an icon in the system tray without a System.Windows.Forms.Form and NotifyIcon?

You are not going to get an Icon in the try without using a NotifyIcon object (unless you want to work with the Windows API), but you can have a notify icon without using a System.Windows.Forms.Form by using the following code:


    static void Main()
    {
      System.ComponentModel.Container components;
      components = new System.ComponentModel.Container();
      using(components)
      {
        System.Windows.Forms.ContextMenu contextMenu;
        contextMenu = new System.Windows.Forms.ContextMenu();

        contextMenu.MenuItems.Add("&Close", new EventHandler(CloseMenuItem_Click));

        System.Windows.Forms.NotifyIcon notifyIcon;
        notifyIcon = new System.Windows.Forms.NotifyIcon(components);
        notifyIcon.Icon = System.Drawing.SystemIcons.Warning;
        notifyIcon.ContextMenu = contextMenu;
        notifyIcon.Visible = true;

        System.Windows.Forms.Application.Run();
      }
    }

    private static void CloseMenuItem_Click(object sender, EventArgs e)
    {
      System.Windows.Forms.Application.Exit();
    }
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now