By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,239 Members | 1,200 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,239 IT Pros & Developers. It's quick & easy.

Windows Service and notyfication icon...

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.