(1) create a new Windows Service Project server1
(2) Open service1CodeView, locate the onstart part, and add the code
(3) switch to the design view, right-click to add and installProgram
(4 ). switch to the newly generated projectinstaller. in the CS design view, locate serviceprocessinstaller1, set the account attribute to LocalSystem, and set the servicename attribute of serviceinstaller1 to server1 (Service name ), starttype attribute is set to automatic (the service is automatically started when the system starts)
(5) Close the project.
(6) create a new installation project serversetup (create an installation project for the service just now)
(7) Right-click and choose "add"> "project output"> "Master output"> "select" service1 ">" OK ".
(8). Right click-View-custom operation-custom Operation Right click-add custom operation-open application folder-select the primary output just now-OK
(9). regenerate the installation project-right-click to install
(10) In the Service Manager (my computer-right-click-Manage-services and applications-services) Find the server1 service and start the service