1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| 'ouverture de la console des services
Public Declare Function OpenSCManager Lib "ADVAPI32.DLL" Alias "OpenSCManagerA" (ByVal lpMachineName As String, ByVal lpDatabaseName As String, ByVal dwDesiredAccess As Long) As Long
'ouverture d'un service
Public Declare Function OpenService Lib "ADVAPI32.DLL" Alias "OpenServiceA" (ByVal hSCManager As Long, ByVal lpServiceName As String, ByVal dwDesiredAccess As Long) As Long
'modification des paramètres d'un service
Public Declare Function ChangeServiceConfig Lib "ADVAPI32.DLL" Alias "ChangeServiceConfigA" (ByVal hService As Long, ByVal dwServiceType As Long, ByVal dwStartType As Long, ByVal dwErrorControl As Long, ByVal lpBinaryPathName As String, ByVal lpLoadOrderGroup As String, lpdwTagId As Long, ByVal lpDependencies As String, ByVal lpServiceStartName As String, ByVal lpPassword As String, ByVal lpDisplayName As String) As Long
Public Declare Function ChangeServiceConfig2 Lib "ADVAPI32.DLL" Alias "ChangeServiceConfigB" (ByVal hService As Long, ByVal dwInfoLevel As Long, lpInfo As Long) As Long
'fermeture d'un handle
Declare Function CloseServiceHandle Lib "ADVAPI32.DLL" (ByVal hSCObject As Long) As Long
Public Function modifService()
Dim scManager As Long
Dim service As Long
Dim ret As Variant
scManager = OpenSCManager(vbNullString, vbNullString, SC_MANAGER_ALL_ACCESS)
service = OpenService(scManager, "Aconvert", SERVICE_CHANGE_CONFIG)
MsgBox ChangeServiceConfig(service, SERVICE_NO_CHANGE, SERVICE_AUTO_START, SERVICE_NO_CHANGE, vbNull, vbNull, ByVal 0&, vbNull, vbNull, vbNull, vbNull)
CloseServiceHandle service
CloseServiceHandle scManager
End Function |