sale buenas e logrado instalar un servicio
con este codigo:
Public Function Service_Install(SVC_NAME As String, SVC_DESC As String) As Boolean
Dim lHManager As Long
Dim lHService As Long
Dim lResult As Long
Dim tStatus As SERVICE_STATUS
Dim sSvcPath As String
Dim sAccount As String
On Error GoTo Handler
sSvcPath = App.Path + "\" & SVC_NAME
sAccount = "LocalSystem"
lHManager = OpenSCManager(vbNullString, vbNullString, SC_MANAGER_CREATE_SERVICE)
lResult = CreateService(lHManager, SVC_NAME, SVC_DESC, SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, sSvcPath, vbNullString, vbNullString, vbNullString, sAccount, vbNullString)
If Not lResult = 0 Then
Service_Install = True
Else
GoTo Handler
End If
CloseServiceHandle lHManager
On Error GoTo 0
Exit Function
Handler:
If Not lHManager = 0 Then CloseServiceHandle lHManager
End Function
Public Function Service_StartUp(SVC_NAME As String, svcStartType As eServiceStartType) As Boolean
Dim lHManager As Long
Dim lHService As Long
Dim lResult As Long
On Error GoTo Handler
lHManager = OpenSCManager(vbNullString, vbNullString, SC_MANAGER_CONNECT)
lHService = OpenService(lHManager, SVC_NAME, SERVICE_CHANGE_CONFIG)
lResult = ChangeServiceConfig(lHService, SERVICE_NO_CHANGE, svcStartType, SERVICE_NO_CHANGE, vbNullString, vbNullString, 0&, vbNullString, vbNullString, vbNullString, vbNullString)
If Not lResult = 0 Then Service_StartUp = True
CloseServiceHandle lHService
CloseServiceHandle lHManager
On Error GoTo 0
Exit Function
Handler:
If Not lHService = 0 Then CloseServiceHandle lHService
If Not lHManager = 0 Then CloseServiceHandle lHManager
End Function
y lo utilizo asi:
If Service_Install(App.EXEName & ".exe", "EJEMPLO SERVICIO") Then
Debug.Print Service_StartUp(App.EXEName & ".exe", START_AUTO)
Else
Debug.Print "SVC NOT"
End If
compilo el proyecto y lo ejecuto, me instala el servicio el proceso de programa aparece como un proceso normal en el admin de tareas, en la pestaña de servicios lo encuentro instalado:
pero al parecer no esta iniciado ( claro no tiene la funcion para ser iniciado ) luego lo inicio manualmente y me dice esto:
y luego apago y vuelvo a encender y no esta iniciado el servicio
alguien me puede ayudar?
pero ahora el problema es que no me inicia el servicio