[Windows Service overview]
Differences between services and applications
You need to attach it to the process for debugging.
You need to create and install
Use event log records for error messages
Use your own User Permissions
..................
Service Lifecycle
Install
Start, Run, pause, and stop
Service Type
Single type (win32ownprocess)
Sharing type (win321_process)
[Create a Windows Service]
Create a "Windows Service" Project
Set the "servicename" attribute
This attribute must match the one in the installation class.
Set the following attributes
Canstop
Can the service be stopped?
Canshutdown
Whether the Service accepts the shutdown message and triggers the onshutdown event
Canpauseandcontinue
Whether the service can be stopped and run
Canhandlepowerevent
Whether the service can control power events
Autolog
Whether the service automatically records information to the applicationProgramEvent Log
CustomCode
Reload onstart, onstop, and other methods
Add an installer for the service and compile the project
Install the created and compiled Windows Service
[Add installer for Windows Service]
Add installer
Right-click a Windows Service and choose add installer.
Set serviceinstaller attributes
The servicename attribute matches the name set in the Windows service.
Set the start type: manual, automatic, and disabled.
Set serviceprocessinstaller attributes
Set security context for services
Reload related methods
To add other services, repeat the preceding steps.
Actually, "serviceinstaller" is added"
All services share one "serviceprocessinstaller"
[Deploy and uninstall Windows Services]
Command Line
Deployment: installutil myproject.exe
Uninstall: installutil/u myproject.exe
Installutil tool Directory: C: \ WINDOWS \ Microsoft. NET \ framework \ v2.0.50727
Installation Method
Right-click the solution and choose new project.
Setup and deployment projects
Setup Project
Right-click the new project, project output, primary output, and OK
Msdn
Windows service applications