c# 作 windows service 的问题 在 windows service 定义的时候可以将其定义为,auto startup, 但是用户可以将其改掉,如何才能使用户不能修改呢?就像 Remote Procedure Call (RPC) ,不允许修改属性 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 类似的属性包括:AutoLog 指示是否在事件日志中报告“开始”、“停止”、“暂停”以及“继续”命令。 CanHandlePowerEvent 获取或设置一个值,该值指示服务是否可以处理计算机电源状态更改通知。 CanHandleSessionChangeEvent 获取或设置一个值,该值指示服务是否可以处理从终端服务器会话接收到的会话更改事件。 CanPauseAndContinue 获取或设置指示服务是否可以暂停并再继续的值。 CanShutdown 获取或设置一个值,该值指示系统关闭时是否应通知服务。 CanStop 获取或设置一个值,该值指示服务启动后是否可以停止。 Container 获取 IContainer,它包含 Component。 (从 Component 继承。) EventLog 获取一个事件日志,它可用于将服务命令调用的通知(如“开始”和“停止”)写入“应用程序”事件日志。 ExitCode 获取或设置服务的退出代码。 ServiceName 获取或设置用于向系统标识服务的简短名称。 Site 获取或设置 Component 的 ISite。 (从 Component 继承。) 可以参考设计器生成的代码,==============================Service1.cs=================================using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Diagnostics;using System.ServiceProcess;using System.Text;namespace Zhengzuo.Test.WindowsService1{ public partial class Service1 : ServiceBase { public Service1() { InitializeComponent(); } protected override void OnStart(string[] args) { // TODO: 在此处添加代码以启动服务。 } protected override void OnStop() { // TODO: 在此处添加代码以执行停止服务所需的关闭操作。 } }}============================Service1.Designer.cs============================namespace Zhengzuo.Test.WindowsService1{ partial class Service1 { /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// 清理所有正在使用的资源。 /// </summary> /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region 组件设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要 /// 使用代码编辑器修改此方法的内容。 /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.timer1 = new System.Windows.Forms.Timer(this.components); // // Service1 // this.AutoLog = false; this.CanHandlePowerEvent = true; this.CanHandleSessionChangeEvent = true; this.CanPauseAndContinue = true; this.CanShutdown = true; this.CanStop = false;//这里进行控制。 this.ServiceName = "Service1"; } #endregion private System.Windows.Forms.Timer timer1; }} WonForm 字幕滚动 C# List容器的使用问题 C#2005问题 c#socket传送文件的怪问题 c#中如何用ScrollBar来控制PictureBox中的图片 项目如何设置,才能在每次编译时,自动给编译版本号加1? 答谢 zztfj(让我来) 的其中100分(3) 如何在数据库中搜索给定的任意关键词 如何将多个查询结果集最高效的结合在一起? 字符串的问题? 转自朋友的贴 高手帮忙看看这个错“拒绝访问”
AutoLog 指示是否在事件日志中报告“开始”、“停止”、“暂停”以及“继续”命令。
CanHandlePowerEvent 获取或设置一个值,该值指示服务是否可以处理计算机电源状态更改通知。
CanHandleSessionChangeEvent 获取或设置一个值,该值指示服务是否可以处理从终端服务器会话接收到的会话更改事件。
CanPauseAndContinue 获取或设置指示服务是否可以暂停并再继续的值。
CanShutdown 获取或设置一个值,该值指示系统关闭时是否应通知服务。
CanStop 获取或设置一个值,该值指示服务启动后是否可以停止。
Container 获取 IContainer,它包含 Component。 (从 Component 继承。)
EventLog 获取一个事件日志,它可用于将服务命令调用的通知(如“开始”和“停止”)写入“应用程序”事件日志。
ExitCode 获取或设置服务的退出代码。
ServiceName 获取或设置用于向系统标识服务的简短名称。
Site 获取或设置 Component 的 ISite。 (从 Component 继承。)
==============================
Service1.cs
=================================
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;namespace Zhengzuo.Test.WindowsService1
{
public partial class Service1 : ServiceBase
{
public Service1()
{
InitializeComponent();
} protected override void OnStart(string[] args)
{
// TODO: 在此处添加代码以启动服务。
} protected override void OnStop()
{
// TODO: 在此处添加代码以执行停止服务所需的关闭操作。
}
}
}============================
Service1.Designer.cs
============================
namespace Zhengzuo.Test.WindowsService1
{
partial class Service1
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null; /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
} #region 组件设计器生成的代码 /// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.timer1 = new System.Windows.Forms.Timer(this.components);
//
// Service1
//
this.AutoLog = false;
this.CanHandlePowerEvent = true;
this.CanHandleSessionChangeEvent = true;
this.CanPauseAndContinue = true;
this.CanShutdown = true;
this.CanStop = false;//这里进行控制。
this.ServiceName = "Service1"; } #endregion private System.Windows.Forms.Timer timer1;
}
}