.Net Windows服务 [英] .Net windows services

查看:59
本文介绍了.Net Windows服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆