📄 btnet_service.cs
字号:
using System;
//compile like so:
//csc btnet_service.cs POP3Main.cs POP3Client.cs
//then run "installutil.exe"
using System.ComponentModel;
using System.Configuration.Install;
namespace btnet {
///////////////////////////////////////////////////////////////////////
public class service : System.ServiceProcess.ServiceBase
{
protected static POP3Main pop3;
public static void Main (string[] args)
{
System.ServiceProcess.ServiceBase.Run(new service());
}
public service()
{
this.ServiceName = "btnet_service";
this.CanStop = true;
this.CanPauseAndContinue = true;
this.AutoLog = true;
}
protected override void OnStart(string[] args) {
bool verbose = false;
pop3 = new POP3Main("c:\\btnet_service.exe.config", verbose);
}
protected override void OnStop() {
pop3.pause();
}
protected override void OnPause() {
pop3.pause();
}
protected override void OnContinue() {
pop3.resume();
}
}
[RunInstaller(true)]
public class ProjectInstaller : System.Configuration.Install.Installer
{
private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1;
private System.ServiceProcess.ServiceInstaller serviceInstaller1;
public ProjectInstaller()
{
this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
this.serviceProcessInstaller1.Password = null;
this.serviceProcessInstaller1.Username = null;
this.serviceInstaller1.ServiceName = "btnet_service";
this.Installers.AddRange(
new System.Configuration.Install.Installer[] {
this.serviceProcessInstaller1,
this.serviceInstaller1}
);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -