?
Solved

Low Impact System Tray Application

Posted on 2004-09-13
2
Medium Priority
?
250 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month8 days, 1 hour left to enroll

765 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