示例#1
0
文件: service.go 项目: postfix/winsvc
// 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
}
示例#2
0
文件: service.go 项目: postfix/winsvc
// 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
}