Прошу разъяснить мне в чём я ошибаюсь при перечислении активных служб:
- Код: Выделить всё
Public Function EnumSystemServices(ctl As Control) As Long
Dim hSCManager As Long, pntr() As ENUM_SERVICE_STATUS, cbBuffSize As Long, cbRequired As Long, dwReturned As Long, hEnumResume As Long, cbBuffer As Long, success As Long, i As Long, sSvcName As String, sDispName As String, dwState As Long, dwType As Long, dwCtrls As Long
hSCManager = OpenSCManager(vbNullString, vbNullString, SC_MANAGER_ALL_ACCESS)
If hSCManager <> 0 Then
success = EnumServicesStatusExA(hSCManager, 0, &H30, 1, ByVal 0, &H0, cbRequired, dwReturned, hEnumResume, 0)
If success = 0 Then
cbBuffer = (cbRequired \ SIZEOF_SERVICE_STATUS) + 1
ReDim pntr(0 To cbBuffer)
cbBuffSize = cbBuffer * SIZEOF_SERVICE_STATUS
hEnumResume = 0
If EnumServicesStatusExA(hSCManager, 0, &H30, 1, pntr(0), cbBuffSize, cbRequired, dwReturned, hEnumResume, 0) Then
With ctl
.Clear
For i = 0 To dwReturned - 1
sDispName = GetStrFromPtrA(ByVal pntr(i).lpDisplayName)
.AddItem sDispName
Next
End With
End If
End If
End If
Call CloseServiceHandle(hSCManager)
EnumSystemServices = dwReturned
End Function
заранее СПАСИБО!