func (m *Mgr) ListServices() ([]string, error) {
	var err error
	var bytesNeeded, servicesReturned uint32
	var buf []byte
	for {
		var p *byte
		if len(buf) > 0 {
			p = &buf[0]
		}
		err = windows.EnumServicesStatusEx(m.Handle, windows.SC_ENUM_PROCESS_INFO,
			windows.SERVICE_WIN32, windows.SERVICE_STATE_ALL,
			p, uint32(len(buf)), &bytesNeeded, &servicesReturned, nil, nil)
		if err == nil {
			break
		}
		if err != syscall.ERROR_MORE_DATA {
			return nil, err
		}
		if bytesNeeded <= uint32(len(buf)) {
			return nil, err
		}
		buf = make([]byte, bytesNeeded)
	}
	if servicesReturned == 0 {
		return nil, nil
	}

	var services []windows.ENUM_SERVICE_STATUS_PROCESS
	hdr := (*unsafeheader.Slice)(unsafe.Pointer(&services))
	hdr.Data = unsafe.Pointer(&buf[0])
	hdr.Len = int(servicesReturned)
	hdr.Cap = int(servicesReturned)

	var names []string
	for _, s := range services {
		name := windows.UTF16PtrToString(s.ServiceName)
		names = append(names, name)
	}
	return names, nil
}
// ListServices enumerates services in the specified
// service control manager database m.
// If the caller does not have the SERVICE_QUERY_STATUS
// access right to a service, the service is silently
// omitted from the list of services returned.
ListServices enumerates services in the specified
service control manager database m.
If the caller does not have the SERVICE_QUERY_STATUS
access right to a service, the service is silently
omitted from the list of services returned.
// ListServices enumerates services in the specified // service control manager database m . // If the caller does not have the SERVICE_QUERY_STATUS // access right to a service the service is silently // omitted from the list of services returned .
func (m *Mgr) ListServices() ([]string, error) {
	var err error
	var bytesNeeded, servicesReturned uint32
	var buf []byte
	for {
		var p *byte
		if len(buf) > 0 {
			p = &buf[0]
		}
		err = windows.EnumServicesStatusEx(m.Handle, windows.SC_ENUM_PROCESS_INFO,
			windows.SERVICE_WIN32, windows.SERVICE_STATE_ALL,
			p, uint32(len(buf)), &bytesNeeded, &servicesReturned, nil, nil)
		if err == nil {
			break
		}
		if err != syscall.ERROR_MORE_DATA {
			return nil, err
		}
		if bytesNeeded <= uint32(len(buf)) {
			return nil, err
		}
		buf = make([]byte, bytesNeeded)
	}
	if servicesReturned == 0 {
		return nil, nil
	}
	var services []windows.ENUM_SERVICE_STATUS_PROCESS
	hdr := (*unsafeheader.Slice)(unsafe.Pointer(&services))
	hdr.Data = unsafe.Pointer(&buf[0])
	hdr.Len = int(servicesReturned)
	hdr.Cap = int(servicesReturned)
	var names []string
	for _, s := range services {
		name := windows.UTF16PtrToString(s.ServiceName)
		names = append(names, name)
	}
	return names, nil
}
func ( m * Mgr ) ListServices ( ) ( [ ] string , error ) { var err error var bytesNeeded , servicesReturned uint32 var buf [ ] byte for { var p * byte if len ( buf ) > 0 { p = & buf [ 0 ] } err = windows . EnumServicesStatusEx ( m . Handle , windows . SC_ENUM_PROCESS_INFO , windows . SERVICE_WIN32 , windows . SERVICE_STATE_ALL , p , uint32 ( len ( buf ) ) , & bytesNeeded , & servicesReturned , nil , nil ) if err == nil { break } if err != syscall . ERROR_MORE_DATA { return nil , err } if bytesNeeded <= uint32 ( len ( buf ) ) { return nil , err } buf = make ( [ ] byte , bytesNeeded ) } if servicesReturned == 0 { return nil , nil } var services [ ] windows . ENUM_SERVICE_STATUS_PROCESS hdr := ( * unsafeheader . Slice ) ( unsafe . Pointer ( & services ) ) hdr . Data = unsafe . Pointer ( & buf [ 0 ] ) hdr . Len = int ( servicesReturned ) hdr . Cap = int ( servicesReturned ) var names [ ] string for _ , s := range services { name := windows . UTF16PtrToString ( s . ServiceName ) names = append ( names , name ) } return names , nil }
ListServices enumerates services in the specified
service control manager database m.
If the caller does not have the SERVICE_QUERY_STATUS
access right to a service, the service is silently
omitted from the list of services returned.
ListServices enumerates services in the specified service control manager database m . If the caller does not have the SERVICE_QUERY_STATUS access right to a service the service is silently omitted from the list of services returned .