471,605 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,605 software developers and data experts.

Windows Service and notyfication icon...

I would like to make a notyfication icon showing
all the time my service is running ... The problem is
that in implementation above requires to check
"Allow interact with desktop" in service properys
tab to work properly ... Why? How to make my
notyfication visible without doing anything manually?

Here's my code...
#region Using directives

using System;

using System.Data;

using System.Text;

using System.Diagnostics;

using System.Windows.Forms;

using System.ComponentModel;

using System.ServiceProcess;

using System.Collections.Generic;

#endregion

namespace Datacomp.FelixService

{

/// <summary>

/// Serwis Windows Felix.

/// </summary>

public partial class FelixService : ServiceBase

{

#region Members

NotifyIcon nI;

#endregion

#region Constructor

/// <summary>

/// Serwis Windows Felix.

/// </summary>

public FelixService()

{

InitializeComponent();

}

#endregion

#region OnStart

/// <summary>

/// Gdy serwis startuje.

/// </summary>

/// <param name="args">Argumenty startu serwisu.</param>

protected override void OnStart(string[] args)

{

nI = new NotifyIcon();

nI.Icon = Properties.Resources.Main;

nI.Text = "Serwis Felix jest uruchomiony...";

nI.Visible = true;

}

#endregion

#region OnStop

/// <summary>

/// Gdy serwis zostaje zatrzymany.

/// </summary>

protected override void OnStop()

{

nI.Visible = false;

nI.Dispose();

nI = null;

}

#endregion

}

}
Feb 14 '06 #1
1 2041
NotifyIcon is a GUI element and needs a window, even if it can be a hidden
window, to process messages. Only services that run with no GUI whatsoever
can be used without the "interact with desktop" setting.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Jacek Jurkowski" <pc*****@priv1.onet.pl> wrote in message
news:eD**************@TK2MSFTNGP14.phx.gbl...
I would like to make a notyfication icon showing
all the time my service is running ... The problem is
that in implementation above requires to check
"Allow interact with desktop" in service properys
tab to work properly ... Why? How to make my
notyfication visible without doing anything manually?

Here's my code...
#region Using directives

using System;

using System.Data;

using System.Text;

using System.Diagnostics;

using System.Windows.Forms;

using System.ComponentModel;

using System.ServiceProcess;

using System.Collections.Generic;

#endregion

namespace Datacomp.FelixService

{

/// <summary>

/// Serwis Windows Felix.

/// </summary>

public partial class FelixService : ServiceBase

{

#region Members

NotifyIcon nI;

#endregion

#region Constructor

/// <summary>

/// Serwis Windows Felix.

/// </summary>

public FelixService()

{

InitializeComponent();

}

#endregion

#region OnStart

/// <summary>

/// Gdy serwis startuje.

/// </summary>

/// <param name="args">Argumenty startu serwisu.</param>

protected override void OnStart(string[] args)

{

nI = new NotifyIcon();

nI.Icon = Properties.Resources.Main;

nI.Text = "Serwis Felix jest uruchomiony...";

nI.Visible = true;

}

#endregion

#region OnStop

/// <summary>

/// Gdy serwis zostaje zatrzymany.

/// </summary>

protected override void OnStop()

{

nI.Visible = false;

nI.Dispose();

nI = null;

}

#endregion

}

}

Feb 14 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Andrew Mueller | last post: by
3 posts views Thread by Mats-Lennart Hansson | last post: by
1 post views Thread by Scott Davies | last post: by
reply views Thread by Scott Davies | last post: by
4 posts views Thread by juliashah | last post: by
4 posts views Thread by tshad | last post: by
1 post views Thread by =?Utf-8?B?VzFsZDBuZTc0?= | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by CCCYYYY | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.