?
Solved

Low Impact System Tray Application

Posted on 2004-09-13
2
Medium Priority
?
253 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 300 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 1200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

840 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