Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am unable display the message box in the fallowing windows service .
can any body help me to overcome this

public partial class Service1 : ServiceBase
{
public Service1()
{
InitializeComponent();
}

protected override void OnStart(string[] args)
{
timer1.Enabled = true;
}

protected override void OnStop()
{
timer1.Enabled = false;
}

private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
Process[] p = Process.GetProcesses();
for (int i=0;i<p.length;i++)>
{
if (p[i].ProcessName.ToUpper() == "WMPLAYER")
{
p[i].Kill();
System.Windows.Forms.MessageBox.Show("your not authorized to open mediaplayer");


break;
}
}
}
}
Posted
Comments
[no name] 8-Jul-13 14:32pm    
You need to log errors in services. Not showing the messagebox is what should happen so there is nothing to "overcome".
Bernhard Hiller 9-Jul-13 2:56am    
If you want to prevent some people from using MediaPlayer, you'd better do that with Group Policies.

1 solution

windows services are not meant to have a GUI.
 
Share this answer
 
Comments
chandubbbb 8-Jul-13 14:31pm    
Ya of course its background process ,if we want to alert user when ever he want to open
windows media player windows service will fetch the process and kill it after that i want to
display some message to him, is it not possible?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900