Chapter 2: Creating and managing Windows services includes understanding Windows services; creating Windows services; handling events and logging information from a Windows services application; adding installers, specifying security context and installing and uninstalling a Windows services.
' ( + ! , - "# $ %& ) ' ( * ' * * ' &RQWHQW ! ! " #! ! ' % % $ '(( ) ( & + & *) ! ! & ୷ %& ,- ! 8QGHUVWDQGLQJ :LQGRZV 6HUYLFHV , - ,& & / , ! - ! # (( - ( & ! ୷ ' HV F U L E H : L QG RZ V V HU Y L F HV ! ' ( - ! ( * ( ) (( ( ( ! ! + & +3 ! ' ୷ ! ! & ' HV F U L E H : L QG RZ V V HU Y L F HV ୷ The Services window of the Administrative Tools component ' HV F U L E H : L QG RZ V V HU Y L F HV ! ( ! (( ! ! ୷ & (( + ' HV F U L E H : L QG RZ V V HU Y L F HV ! - # ! # : ( & ! ! % & ! ; ! % " # '$ =+' "% #? < #+? ? ! ! () ( ୷ ) + ) ! ' L I I HU HQWL D WH E HWZ HHQ : L QG RZ V V HU Y L F HV D QG RWK HU ( D S S O L F D WL RQV % ! ! (( / -& ,- ( A ) ! ! :5) :BB1 - ( #* & ! C < ! ! (( ! - ୷ ! ) ! C & + + & -* @ 3URJUDPPLQJ 0RGHO RI :LQGRZV 6HUYLFH $SSOLFDWLRQV ! ( , ! ; ! % ! % < ! ! ; ! (( & ( ! ( & (( ! ! ୷ D 3URJUDPPLQJ 0RGHO RI :LQGRZV 6HUYLFH $SSOLFDWLRQV , ( ( , #! $ ' ,- ! ! ( ( ! ( ( * ( & & F ୷ BE 6SHFLI\ LQJ 6HFX ULW\ & RQWH[ W IRU D 6HUYLFH $SSOLFDWLRQ ( ( # / & ! & ' ( + $ % , ! $ # * ! ( ! (! # (! ! ( * & ( ! ( ! & ! * & ( ( ! * & ( ( ! ! ! # (! ! & # ! (( ୷ ( ! ! * & ( ( < (( ! , QVWDOOLQJ DQG QLQVWDOOLQJ D :LQGRZV 6HUYLFH % H *& #* ( 7% % + G H *& #* ( 7% ୷ I ! * I G + ! * / HV V RQ D QD J L QJ : L QG RZ V HU Y L F HV ! + See Text Book page 77-82 ୷ V L QJ WK H HU Y L F H &RQWU RO D QD J HU ୷ V L QJ WK H HU Y L F H &RQWU RO D QD J HU J $ ୷ V L QJ WK H HU Y L F H &RQWU RO D QD J HU C ! ,( ୷ 8 V L QJ WK H HU Y L F H&RQWU RO O HU &O D V V ! / & ! ( ! K ( & ! ୷ ( ! ! ( ( & ! * @ $ G G WK H HU Y L F H&RQWU RO O HU F RP S RQHQW #* ( ! ! , ( C ' ୷ D $ G G WK H HU Y L F H&RQWU RO O HU F RP S RQHQW ( ( + ! private ServiceController serviceCtr1; this.serviceCtr1 = new ServiceController(); this.serviceCtr1.MachineName = “."; this.serviceCtr1.ServiceName = "DBWriter"; ୷ 0E ( [ D P S O H ದ HU Y L F H&RQWU RO O HU ( ( See Text Book page 85-86 (( ) ) B.3 private void StartService() { if (DBWriterController.Status == ServiceControllerStatus.Stopped) { DBWriterController.Start(); MessageBox.Show("Service Started"); } else MessageBox.Show("Service Running"); } ୷ 0B &X V WRP ୷ &RP P D QG V WR HU Y L F H $ S S V V L QJ WK H ( [ HF X WH&RP P D QG P HWK RG #* ! ! - ! B@ ( - 563 > >! ୷ #* V L QJ WK H ( [ HF X WH&RP P D QG P HWK RG void RunCommand() { if(System.DateTime.Now.Hour