Create and Control Windows Services--introduction[等级:高级]

services|window|高级

Windows Services (formerly known as NT Services) can seem overwhelming and daunting to the uninitiated because of a vast array of callback functions and long parameter lists. Even though creating services in C++ almost ensures top-notch performance, the complexity factor might outweigh that fact. However, with the recent release of the .NET Framework SDK, the complexity of creating and controlling services has diminished. If development time is of the essence, Visual C#.NET and the .NET Framework prove invaluable assets.

What you need:
.NET Framework SDK, Windows NT4 or Windows 2000   

In this article, I'll demonstrate the necessary steps to create a Windows Service, then explain how to control your service by creating a useful utility that could prove invaluable as you test and debug your service. But first let me give you some background on Windows Services.

Most of us remember terminate-and-stay-resident (TSR) programs—ones that remained in memory after being executed but gave control back to the user. As useful as they were, you faced the occasional compatibility problem in the environment you ran them in. System architectures inevitably increased in reliability and multitasking capabilities, and the TSR gave rise to what we now call the service.

A service is an executable that gives the operating system nonintrusive functionality. A service installed and configured to run automatically begins execution before a user logs on to the computer. Some common uses for services include hardware control and monitoring applications; system-level utility, diagnostic, and reporting tools; and communication software such as a Web or file-system server.

Although a service is an executable, you can't start and terminate it through traditional means. The first and most common way to start one: Register it with the Service Control Manager as an automatic service. This ensures the service starts as soon as the machine has finished the boot cycle and before a user logs on to the system. You can also start a service manually using the console command NET START <servicename> or through the service applet within the Windows Administrative tools group.

Services also can allow you to pause and continue during execution, either manually or programmatically. But providing this functionality is up to the service designer—it's not required.

Just as a service doesn't start as other executables do, it also can't terminate the same way many other executables can. The service itself generally has no user interface associated with it, so it terminates when the user turns off or restarts the system, or manually stops the service using the service applet again or with the NET STOP <servicename> console command.

You must follow special rules while creating a service to get it to run correctly within the system environment. The most important: You must install or register a service within the system it intends to run in. In other words, you can't just run a service by double-clicking on its executable file. Furthermore, a service shouldn't provide a user interface. Rather, it should do its reporting with the system event log or performance counters. I'm not saying services can't have a user interface, but each service is created within in its own Windows station, so UI-related API calls might not succeed. Finally, a service must support a number of methods I'll discuss later to control its execution life cycle.

时间: 2024-10-06 14:24:17

Create and Control Windows Services--introduction[等级:高级]的相关文章

Create and Control Windows Services--Control Your Service[等级:高级]

services|window|高级 You've created your service-now it's time to create the service controller. Use the System.ServiceProcess namespace's ServiceController class to interface programmatically with the Service Control Manager to start, stop, pause, res

Create and Control Windows Services--Not a Slap Shot, but Almost as Fast[等级:高级]

services|window|高级 Not a Slap Shot, but Almost as FastCreating the service using .NET is fairly straightforward. You use the .NET Framework's System.ServiceProcess namespace and four classes within it: ServiceBase, ServiceInstaller, ServiceProcessIns

Create and Control Windows Services--Add File-Monitoring Functionality[等级:高级]

services|window|高级 Now that all the necessary architecture is in place, you can add some functionality to the service. As an example, I'll show you how to build a file-monitoring service that monitors the local file system and notes important activit

metasploit之Windows Services漏洞提权实战

本文讲的是metasploit之Windows Services漏洞提权实战, 0×01引言 在获得目标机器基本权限以后,面临我们最大的问题就是如何从普通用户提升为管理员用户.众所周知,Windows服务是以SYSTEM权限运行的,因此,它们的文件夹.文件和注册的键值,都是受到强访问控制保护的.但在某些情况下,会有一些没有受到有效保护的服务. 0×02 Windows服务漏洞介绍 windows服务漏洞.Windows系统服务运行在后端,由操作系统通过SCM(服务控制管理)控制,它负责处理所有发

C# Windows Phone 8 WP8 高级开发,制作不循环 Pivot ,图片(Gallery)导览不求人! 内附图文教学!!

原文:C# Windows Phone 8 WP8 高级开发,制作不循环 Pivot ,图片(Gallery)导览不求人! 内附图文教学!! 一般我们在开发Winodws Phone APP 的时候往往需要使用照片浏览的功能,但是在Windows Phone 8 SDK 中的控制向并没有提供类似Gallery的元件(好比 Android 的 ViewPager),这对开发者来说是非常不方便的,因为如果要自己制作一个控制项是非常的颢时间,而且说不定还有修不完的Bug,所以我们可以透过修改WP8 S

安装window服务失败-安装windows services服务失败

问题描述 安装windows services服务失败 解决方案 提示你了,看日志.贴具体错误出来才知道.

Windows 7的NTFS高级应用

微软从Windows 2000开始引入了NTFS文件系统,但此时用户可以选择将系统安装在非NTFS格式的分区中.到了当前,Windows 7却只能安装在NTFS格式中了.这其中我们可以看到微软对NTFS的器重,当然和当年相比其特性和功能有了很大的扩展和提升.不过,对于NTFS的诸如压缩.加密.安全授权等功能大家比较熟悉,本文将以Windows 7系统为例,谈谈其下的NTFS高级特性和应用.Vista下的NTFS管理请参考文章<打通NTFS权限 文件共享各取所需>(http://winsyste

Windows 2000 安全检查清单-高级篇

高级安全篇 1.关闭DirectDraw 这是C2级安全标准对视频卡和内存的要求.关闭DirectDraw可能对一些需要用到DirectX的程序有影响,但是对于绝大多数的商业站点都应该是没有影响的. 修改注册表 HKLMSYSTEMCurrentControlSetControlGraphicsDriversDCI 的Timeout(REG_DWORD)为0即可. 2.关闭默认共享 win2000安装好以后,系统会创建一些隐藏的共享,你可以在cmd下打 net share 查看他们.网上有很多关

Windows 8 中使用高级启动

  1.系统下按"Windows+C"键打开应用Charm菜单 ,选择"设置". 参见下图 2.在右侧弹出菜单中选择"更多电脑设置".参见下图 3.在左侧菜单栏选中"常规",在"常规"右侧菜单选择"高级启动"下的"立即重启". 参见下图 4.计算机重启后选择"疑难解答". 参见下图 5.在"疑难解答"下面选择"高级选项