Creation, control of Windows services

zhaozj2021-02-16  64

1. Create, open vs.net, create a new project, type Windows Service2, installation, installutil service1.exe installutil / u service1.exe delete 3, control ServiceController sc = new serviceController (SC.Start (); sc.start (); .stop (); sc.continue (); 4, transfer message in service1.cs // Command Must Between 128-256Protected Override Void oncustomCommand (INT command) {if (Command == 130) this.Eventlog1.writeentry (" the 130 service1 stop "); if (command == 140) this.eventLog1.WriteEntry (" the 140 service1 stop ");} in the control file ServiceController myController = new ServiceController (" service1 "); myController.ExecuteCommand (130) ;

转载请注明原文地址:https://www.9cbs.com/read-17590.html

New Post(0)