.Net Windows服务 [英] .Net windows services
问题描述
我无法在fallowing windows服务中显示消息框。
任何人都可以帮助我克服这个问题
公共部分类服务1:ServiceBase
{
公共服务1()
{
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)
{
处理[] p = Process.GetProcesses();
for(int i = 0; i< p .length; i ++)>
{
if(p [i] .ProcessName.ToUpper()==WMPLAY ER)
{
p [i] .Kill();
System.Windows.Forms.MessageBox.Show(你未经授权打开媒体播放器);
休息;
}
}
}
}
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;
}
}
}
}
推荐答案
Windows服务不具备GUI。
windows services are not meant to have a GUI.
这篇关于.Net Windows服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!