Solved

Low Impact System Tray Application

Posted on 2004-09-13
2
236 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
insert image with its metadata into SQL server Database 3 88
COnsume rest client 6 36
How to LOAD up a .NET Framework website with data? 2 40
Name space syntax error 12 40
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…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

911 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

22 Experts available now in Live!

Get 1:1 Help Now