如何在c#.net中为系统启动创建Windows服务? [英] How to create windows service for system start in c# .net?

查看:95
本文介绍了如何在c#.net中为系统启动创建Windows服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



如何在c#.net中为系统启动创建Windows服务?



我的窗口服务应该在用户系统打开时启动。

或OnElapsed时间应该在用户系统打开时启动。



没有任何具体的Windows服务开始的时间。



请帮帮我。



先谢谢。



Ankit Agarwal

软件工程师

Hello,

How to create windows service for system start in c# .net?

My window service should be start,when user system open.
or OnElapsed time should be start when user system open.

Not any specific time for windows service start.

Please help me.

Thanks in Advance.

Ankit Agarwal
Software Engineer

推荐答案

任何Windows服务都可以从系统启动开始。这是由其启动选项定义的;请参阅服务控制面板小程序。



可以使用类 Microsoft.Win32.SystemEvents

http://msdn.microsoft.com/en-us/library/microsoft.win32.systemevents%28v=vs.110%29.aspx [ ^ ]。



-SA
Any Windows Service can start with system start. This is defined by its start options; please see the "Services" Control Panel applet.

Other system events can be handled by using the class Microsoft.Win32.SystemEvents:
http://msdn.microsoft.com/en-us/library/microsoft.win32.systemevents%28v=vs.110%29.aspx[^].

—SA


Windows服务在计算机启动时自动启动。它们不需要登录用户即可执行,并且可以在包括系统在内的任何用户的上下文中运行。 Windows服务通过服务控制管理器进行控制,可以根据需要停止,暂停和启动它们。
Windows Services are started automatically when computer is booted. They do not require a logged in user in order to execute and can run under the context of any user including the system. Windows Services are controlled through the Service Control Manager where they can be stopped, paused, and started as needed.


这篇关于如何在c#.net中为系统启动创建Windows服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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