Create a project-Visual C # project-Windows service.
2. After modifying the corresponding class name, drag and drop the corresponding components on the class design page. 3. You can perform corresponding operations on OnStart and OnStop, such as writing a service running Log to DB. 4. Handle the event of the drag-and-drop component accordingly. (The eventLog component is usually used to record the running logs of events. In this case, you need to specify the Log and Source attributes. Log is divided into three types: application, security, and system, specifies the service program to which Source logs are written.) 5. use the install class to switch to the project design page. Click the "add installer" option in the lower right of the Properties window,.. Net automatically adds a project installer. cs file. The design screen of this file contains two controls: serviceProcessInstaller1 and serviceInstaller1. 6. Set the Account (Account type) of serviceProcessInstaller1. Select LocalSystem to run the local system Account or select User. In this case, you can specify the User name and password. 7. You can specify the StartType attribute of serviceInstaller1, indicating whether the service runs automatically or manually. 8. compile the project and find the executable file suffixed with .exe in the bin/debugdirectory. 9. open start-program -- Microsoft Visual Studio. NET 2003 -- Visual Studio. NET tool -- Visual Studio. NET 2003 command prompt 10. enter the bin/debug directory of the current project in the command prompt. 11. Enter
Installutil
Executable File name after compilationThe service is successfully installed. 12. Then you can view the created Service in Control Panel-management tools-service. 13. Enter
Installutil/u
Executable File name after compilation, Will uninstall the service. 14. Each modification to the original program requires uninstallation, recompilation, and re-installation.