Exemple #1
0
// Query returns current status of service s.
func (s *Service) Query() (svc.Status, error) {
	var t winapi.SERVICE_STATUS
	err := winapi.QueryServiceStatus(s.Handle, &t)
	if err != nil {
		return svc.Status{}, err
	}
	return svc.Status{
		State:   svc.State(t.CurrentState),
		Accepts: svc.Accepted(t.ControlsAccepted),
	}, nil
}
Exemple #2
0
// Control sends state change request c to servce s.
func (s *Service) Control(c svc.Cmd) (svc.Status, error) {
	var t winapi.SERVICE_STATUS
	err := winapi.ControlService(s.Handle, uint32(c), &t)
	if err != nil {
		return svc.Status{}, err
	}
	return svc.Status{
		State:   svc.State(t.CurrentState),
		Accepts: svc.Accepted(t.ControlsAccepted),
	}, nil
}