Working with Windows Service Using VS 2005

发明专利电子申请避坑实录:用 Python 脚本把 DOCX 转成 XML+ZIP,踩了 4 个坑 2026年11月实测验证,通过Python脚本自动化生成符合国知局DTD的XML并打包为zip,实现发明专利申请四书(权利要求书、说明书、附图、摘要)的高效电子提交。核心做法:全程使用build/目录下脚本流水线转换,避免手工写XML或系统编辑器;说明书表格转图片以规避服务器500错误;将<heading>降级为<p>解决预览空白问题;申请人代表需在弹窗中手动勾选;提交前严格校验段号连续、图片引用一致、无DOCTYPE等细节。关键结论:上传成功≠预览正常,必须亲测预览;官方公开DTD 阅读详情

Abstract

In this article, I will describe how to implement, setup, install Windows Services with the help of snapshots.

Introduction

A Windows Service is a program which runs continuously in the background of an Operating System. It was formerly known as NT services. Window service internally uses the Service Control Manager (SCM) of the operating system. A service must be installed in an SCM database before it can be launched. SCM controls the entire lifetime of each installed service.

Implementing Windows services has become the choice of the current era of business as it requires minimum human intervention after deployment and gives long running functionality. We also say Window service application works as an Engine; once started it will keep running until the machine shuts down or gets some abnormal error.

Building a Windows Service

Create a Windows Service project in Visual Studio 2005 as given below:

File >> New >> Project

It will open the New Project window. Choose the following settings:

  • Project types: C# >> Windows
  • Visual Studio installed templates: Windows Service
  • Name: MyService

Specify the location for the solution and let the solution name be MyService. Select the check box for "create directory for solution."

Figure 1 – Creating new Windows service project using Visual Studio 2005 IDE

Click OK to create the solution and project. The IDE will automatically add a Service1.cs class file in the project MyService; rename Service1.cs into MyService.cs. Switch to the code view of MyService.cs and open the OnStart function of the MyService class. Add the following codes in the OnStart function:

protected override void OnStart(string[] args) { // TODO: Add code here to start your service. const Int32 iTimer_Interval = 60000; Timer oTimer; System.IO.File.AppendAllText("C:\\MyLog.txt", "MyService has been started at " + DateTime.Now.ToShortTimeString()); System.Threading.TimerCallback tDelegate = EventAction; oTimer = new System.Threading.Timer(tDelegate, this, 0, iTimer_Interval);}

Next, implement EventAction procedure in the MyService class. Note that the EventAction is the procedure which is to be fired/called at each timer interval of 60 seconds raised by Timer implemented in OnStart function above. For a simple example, we will implement to write the current time in a text file MyLog.txt in C drive. Add the following code in the MyService class for EventAction procedure:

public void EventAction(object sender) { System.IO.File.AppendAllText("C:\\MyLog.txt", "MyService fires EventAction at " + DateTime.Now.ToShortTimeString());}

Now we need to add installer components in the service project to set service setup properties. Installer components provided in Visual Studio automatically create Operating System environment objects like registry keys, Windows services control manager event handlers, executables for installation utilities when installing a service application, SCM initialization, etc.

To Add Installer in the Windows Service

Open the MyService.cs file in design view. Right click on the form and choose Add Installer in the pop up menu:

This will add a new file ProjectInstaller.cs with two controls, ServiceProcessInstaller1 and ServiceInstaller1, in the project. Select ServiceProcessInstaller1 and press F4 to open its properties window. Set the Account type to LocalSystem.

Now select the ServiceInstaller1 control and press F4 to go to its properties window. Set the ServiceName as "MyService" and StartType as "Automatic." Setting StartType to automatic will automatically start the service (after installation) whenever the computer restarts.

Build the MyService project. If the build is successful, then we are ready with the service. Now to install this service in the system, we need an installer/setup file. So we will create and add a setup project for the service in the current solution through which we can install/uninstall the service.

Building a Setup for the Windows Service

In the solution "MyService," follow the steps given below to create a setup project.

File >> Add >> New Project

It will open the Add New Project window. Choose the following settings:

  • Project types: Other Project Types >> Setup and Deployment
  • Visual Studio Installed Templates: Setup Project
  • Project Name: MyServiceSetup
  • Click OK to create the project. The setup project MyServiceSetup will be added in the solution and IDE will show you the file system window for the setup.

Right click on the project MyServiceSetup and choose View >> Custom Actions from the pop up menu. It will open the Custom Actions settings window for the setup deployment. Right click on the Custom Actions Node and choose "Add Custom Actions."

After clicking on "Add Custom Actions" a window will appear to select the item for the deployment.

Double click on the "Application Folder." The "Add Output" button will be enabled now. Click on it to open the "Add Project Output Group" window.

In this window, choose the "Primary Output" under MyService and Click the "OK" button. You will see that a new entry Primary output from MyService (Active) in the parent "Select Item in Project" window. Click OK to complete the custom settings.

Now Build the MyServiceSetup project. If the build is successful, then you can find MyServiceSetup.msi file in …\MyServiceSetup\Debug folder.

Installing Windows Service using IDE

You can use setup file MyServiceSetup.msi to install/uninstall the service MyService on any computer. Also you can use Visual Studio 2005 IDE to install the service using setup project. I prefer to use IDE to install/uninstall services as it is convenient during implementation and debugging.

To install MyService using Visual Studio 2005 IDE, right click on the MyServiceSetup project in the solution explorer and choose Install in the pop-up menu.

It will open the window installer wizard. Click Next button and specify the installation folder location in the folder location text box. Click Next button. It will show you the confirmation window. Click Next to start the installation. It will show you the installing status and then completion message window. Now the service should be installed in the machine. Let us find and start the service as given in the next section.

Starting the Installed Windows Service

Reach the installed Services following any of the methods given below.

Open Service Control Manager: Control Panel >> Administrative Tools >> Services.

OR

Right click on My Computer, choose Manage. It will open the Computer Management window. In the tree view, open Services and Applications and click Services.

OR

In the Visual Studio 2005 IDE, open Server Explorer by pressing CTRL+ALT+S and choose node Services under the machine name of Servers tag.

Find the MyService in the list. Right click on it and choose Start to start the service.

Now the service MyWinService has been started and its status should be changed to "Started" in the list. Remember that this sample service is implemented to write log time in a text file "C:\MyLog.txt". For the confirmation of the accuracy of service, you can verify the existence of file. The service should write the current time in the file MyLog.txt at each interval of 60 seconds. If it is so, then we are sure that service is performing as per the implementation.

WIFI中CSI的读取 学习目标: 目前正在做基于WIFI的无设备定位,准备使用信道状态信息(CSI),学习一下。 目前采集数据环境已经搭建好,准备研究信号的预处理。 学习内容: 1、 信号的读取——read_bf_file函数的研究 2、 3、 4、 1. read_bf_file详解: %READ_BF_FILE Reads in a file of beamforming feedback logs. % This version uses the *C* version of read_bfee, ... 阅读详情

相关推荐

国内合规开通ChatGPT Plus实操指南:银行卡绑卡与支付全解析

ChatGPT Plus 是 OpenAI 官方推出的高级订阅服务,基于 GPT-4o 多模态大模型提供语音交互、图像理解与长上下文处理能力。其核心使用前提在于完成合规的国际支付绑定,而非网络接入方式。技术原理上,OpenAI 采用 Stripe 支付网关进行风控校验,重点匹配银行跨境权限、卡片类型(仅支持 Visa/Mastercard/Amex 信用卡)、BIN 号段及地理位置一致性。该机制决定了95%的绑卡失败源于银行端配置缺失或卡片不兼容,而非网络问题。实际应用中,PayPal 作为中间支付层可显著

chuannaoxuan4674的博客 2274

VS2005开发的Windows服务程序实例

(下面是我自己的讲义中摘取的部分)  三、创建一个最简单的Windows服务程序(DEMO:ServiceTest)这个程序的功能很简单,就是定时的让主板的喇叭发出一个声音。要使得一个Windows服务程序能够正常运行,我们需要像创建一般应用程序那样为它创建一个程序的入口点。在Windows服务程序中,我们也是在Main()函数中完成这个操作的。首先我们在Main()函数中创建

eNet 8927

S4-FPGA-K7板级原理图硬件实战

xilinx K7板级硬件实战

weixin_66510961的博客 6169

Visual Studio 2005 创建Windows服务程序(C#)

<br />http://www.cnblogs.com/ruiyi1987/archive/2009/07/30/1535291.html<br />Visual Studio 2005 创建Windows服务程序(C#) 1、新建项目 打开VS—>文件—>新建—>项目—>Visual C#—>Windows—>Windows服务->起个名儿—>确定 (如图) 2、添加Timer组件 从工具箱—>"组件"下拉列表中拖动一个Timer控件到设计视图上注意:看看这个Timer控件的属性中的命名空间是什么,如果

matriculate的专栏 2290

基于ZYNQ的HP总线与DDR交互:实现PL与PS高效数据传输的完整指南

本文将深入探讨如何通过AXI HP总线实现PL与PS的DDR交互,结合代码示例、硬件配置与创新优化,助力开发者掌握这一关键技术。ZYNQ内部通过AXI HP接口直接连接PL与DDR控制器,PL通过AXI协议发送读写请求,绕过PS的CPU直接操作DDR。通过AXI HP总线实现PL与PS的DDR交互,开发者可充分发挥ZYNQ异构架构的优势。在Xilinx ZYNQ系列芯片中,PS(Processing System)与PL(Programmable Logic)的协同设计是其核心优势。

QQ_778132974的博客 1230

基于MATLAB编程的LSTM的时间序列预测

时间序列预测,回归分析,LSTM详细原理

abc991835105的博客 367

SQL Server内存管理核心原理与实战诊断

SQL Server内存管理并非简单分配物理内存,而是基于SQLOS运行时与Windows虚拟内存系统协同工作的复杂机制。其核心在于理解三层架构(Memory Node、Memory Clerk、Buffer Pool)、内存压力响应逻辑及MPA与LPIM等关键概念。技术价值体现在精准定位性能瓶颈——如Buffer Pool Churn、PLE骤降、QEReservations异常飙升等典型问题。应用场景覆盖金融、电商等高负载OLTP/OLAP系统,尤其在IO等待高、缓存命中率低、任务管理器内存显示失真等故

561

基于DSIFT多尺度图像融合的MATLAB代码

多尺度图像融合是一种常用的图像处理技术,它可以将具有不同尺度和空间频率特征的图像融合成一幅更具信息丰富度和视觉效果的图像。DSIFT算法是一种基于SIFT算法的改进版本,它在提取图像特征时采用了密集采样的方法,能够有效地提取图像的局部特征。多尺度图像融合基于DSIFT算法的思想,通过在不同尺度下提取图像的DSIFT特征,并将这些特征进行融合,得到最终的融合图像。然后,通过DSIFT算法提取了两幅图像的特征。通过运行上述代码,我们可以在MATLAB中实现基于DSIFT多尺度图像融合的算法,并观察到融合结果。

IELLQUI9的博客 188

拆解Web渗透底层逻辑:从溯源发展史到实战核心全维度指南

Web渗透测试是一套标准化、流程化、逻辑化、合规化的完整技术体系,绝非零散工具的堆砌。1. 信息收集是渗透的基石,决定测试深度与成功率,核心在于精细化、绕过防护挖掘隐性信息;2. 高危漏洞探测与利用是核心突破,需吃透漏洞原理,规避工具误报、WAF拦截等问题;3. 权限提升与内网渗透是进阶核心,是区分入门与资深渗透工程师的关键;4. 日志清理与复盘是职业化核心,适配企业合规测试场景。从发展趋势来看,Web安全攻防对抗会持续升级,自动化渗透、AI漏洞挖掘、云原生安全、API安全将成为未来主流方向。

2501_92125808的博客 624

uniapp微信小程序 - 详解map地图markers图标不显示问题,自定义图标真机调试不显示变成默认marker标记点图标(解决微信小程序map组件markers自定义图标失效,兼容安卓苹果手机)

uniapp微信小程序 map地图markers图标不显示,markers图标真机调试不显示,uniapp map地图显示图标markers问题,自定义图标不显示,添加marker后不显示,uniapp 微信小程序 map marker图标不显示如何解决,uniapp小程序地图的marker图标不显示问题,微信小程序map组件markers自定义图标真机显示问题,uni-app, 微信小程序, map组件, markers图标不显示, 真机调试, 微信小程序map组件,地图加载后marker标记点ios设备

🏆 前端领域优质创作者 2925

18、Excel VBA编程:自定义函数创建与代码调试全攻略

本文详细介绍了Excel VBA中自定义函数的创建方法,以获取单元格注释为例演示了完整开发流程,并深入讲解了代码调试的重要性与核心工具。内容涵盖三种主要错误类型及其应对策略,系统介绍了调试工具栏、断点、逐行执行、Locals窗口、Immediate窗口等实用功能。通过综合案例展示了如何运用调试技术解决实际问题,并总结了提前规划、逐步测试、日志记录等最佳实践,帮助读者提升VBA编程效率与代码质量。

life6的博客 102

大型CAx(CAD/CAE/CAPP/CAM)工业软件开发中的关键组件

通过对FreeCAD、SALOME等多款代码的分析研究,发现这些软件在架构设计、模块实现等方面,存在许多相似(同)的技术思想。因此,有必要对这些共性、主流的技术予以总结分析。

国产CAx(CAD/CAE/CAM)软件研发 1万+

数字 IC 笔试面试必考点(1)FPGA 芯片架构

FPGA 芯片架构是非常重要的,如果你不了解 FPGA 芯片内部的详细架构,那么...

新芯设计的博客 2825

学习C#开源报表组件Seal Report(46:LINQ数据源使用示例——Excel文件)

学习基于LINQ数据源从EXCEL文件中抓取数据的基本方式。

gc_2299的博客 217

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

测试C#使用AngleSharp解析Html网页的基本用法

学习C#调用AngleSharp解析本地Html网页文件的基本用法

gc_2299的博客 15

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

C#开发HTTP服务端侦听GET、POST请求解析Json获取刷卡机上传卡号

本文实现了一个基于TCP协议的Windows Forms服务端程序,用于接收并响应客户端(如智能设备)的连接请求。通过绑定指定IP和端口开启侦听,支持多客户端并发连接,采用后台线程处理通信。服务端可解析GET、POST及JSON格式数据,提取卡号、设备信息等参数,并根据配置返回响应指令,包括显示内容、语音提示、蜂鸣器控制等。代码包含跨线程更新UI、中文编码转换、数据包解析等功能,适用于物联网设备通信场景。

64

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

C#打断多段线实现方法

可以。在 C# 环境下(基于 AutoCAD .NET API 或 ODA Platform),打断多段线的核心逻辑与 C++ 一致,主要依赖方法。该方法将原始曲线在指定参数处分割,返回一个包含新生成曲线段的集合。开发者需在事务中删除原始多段线,并将集合中的新实体添加到数据库模型空间中。

m0_66048236的博客 193

C#使用RapidOcrNet识别图片文本,OCR组件

RapidOcrNet图片文本识别,OCR组件,支持跨平台

u011511086的专栏 84

(开源)助农销售系统实战指南 基于 C# + ASP.NET Core + Vue + MySQL

这是一个基于 ASP.NET Core + Vue + MySQL 构建的完整助农销售系统,功能持续优化中...用户登录 用户注册 商品信息 商品分类管理 商品信息评论 商家管理 商品订单 购物车管理 收货地址管理 我的收藏管理 用户个人中心 修改密码 找回密码 系统用户管理 系统配置管理

小小码农身兼魔法师职位!除你武器~ 328

在鸿蒙 PC 上原生跑通 Rust 编译器:不用虚拟机、不用交叉编译,官方 dist + 内核签名全链路适配实录

本教程完整记录开源录屏与 GIF 制作工具 ScreenToGif(原 C#/.NET 9 + WPF)在 OpenHarmony / HarmonyOS PC 上从零到跑通的适配过程:每一步做什么、遇到什么报错、怎么定位、改哪一层、如何确认生效。所有命令与报错均真实执行并留档,完整方案与证据见 (附录与验收报告)与 。适配没有搬运 C#/WPF 代码,而是「以 ScreenToGif 为行为规格」重新构建链路。界面层由原版的 WPF/XAML Ribbon 换为 ArkTS + ArkUI(Ribbon

m0_55927959的博客 1万+

C# Web API 第一课(上):一次请求的完整链路、7 个 HTTP 方法、模型绑定与路由,把 HelloApi 三个接口拆开看

步发生什么出问题时你会看到1客户端把拆成 host + path端口写错 → 连接被拒绝2TCP 三次握手连上 5078服务没启动 →无法连接到目标计算机3发 HTTP 请求行 + 请求头(+ 请求体)缺→ 4154Kestrel 解析,交给 ASP.NET Core 管道5路由匹配:找哪个控制器的哪个方法路径不对 → 4046方法匹配:GET 还是 POST方法不对 → 4057模型绑定:把 URL / 查询串 / Body 填进参数JSON 格式错 → 4008。

2501_94699871的博客 189

VS Code 配置 C# 开发环境(.NET 10 LTS)

本文详述如何用轻量级的 VS Code 与 .NET 10 LTS 构建高效 C# 开发环境。涵盖 SDK 安装(含离线加速)、扩展配置、项目创建、F5 断点调试及 NuGet 管理,全程实测可用。无需安装 Visual Studio,跨平台支持,适合现代 C# 开发,特别推荐新项目使用 .NET 10 LTS。

Joey 的工作空间~ 522

学习C#开源报表组件Seal Report(50:LINQ数据源使用示例——HTML文件续)

学习基于LINQ数据源从本地HTML文件中抓取数据的基本方式

gc_2299的博客 16

C# Wpf写了一个无线投屏程序Android +iOS投屏

该投屏方案无需在移动端安装任何软件,操作简便。但存在约100ms的延迟,可能影响实时性体验。适用于对延迟不敏感的场景,如演示、展示等。效果图清晰展示了投屏效果,整体体验良好。

遇见--专栏 13

LeetCode //C - 1320. Minimum Distance to Type a Word Using Two Fingers

This problem involves finding the minimum total distance to type a given word using two fingers on a keyboard layout where letters are arranged in a grid. The solution uses dynamic programming to track the positions of the two fingers after each keystroke,

Made in Code 541

Java开发者学习C#(2)-基础数据类型

本文系统对比了Java与C#在基础数据类型上的核心差异,涵盖类型体系、整数/浮点精度、装箱机制、默认值及转换行为。关键区别包括:C#支持无符号类型与decimal高精度十进制,类型统一为值类型;Java采用“基本类型+包装类”双轨结构,装箱自动但需注意==比较陷阱。两语言在泛型使用、溢出控制和跨语言迁移中各有优劣,开发者应根据场景合理选型。

modelmd的博客 271
上一篇: 软件工程师能力自我评价表
下一篇: XP的IIS连接数修改方法,突破默认最大连接数10
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值