'winsrv.ab

#ifdef UNICODE
Const _FuncName_ChangeServiceConfig = "ChangeServiceConfigW"
Const _FuncName_ChangeServiceConfig2 = "ChangeServiceConfig2W"
Const _FuncName_CreateService = "CreateServiceW"
Const _FuncName_EnumDependentServices = "EnumDependentServicesW"
Const _FuncName_EnumServicesStatus = "EnumServicesStatusW"
Const _FuncName_EnumServicesStatusEx = "EnumServicesStatusExW"
Const _FuncName_GetServiceKeyName = "GetServiceKeyNameW"
Const _FuncName_GetServiceDisplayName = "GetServiceDisplayNameW"
Const _FuncName_OpenSCManager = "OpenSCManagerW"
Const _FuncName_OpenService = "OpenServiceW"
Const _FuncName_QueryServiceConfig = "QueryServiceConfigW"
Const _FuncName_QueryServiceConfig2 = "QueryServiceConfig2W"
Const _FuncName_QueryServiceLockStatus = "QueryServiceLockStatusW"
Const _FuncName_RegisterServiceCtrlHandler = "RegisterServiceCtrlHandlerW"
Const _FuncName_RegisterServiceCtrlHandlerEx = "RegisterServiceCtrlHandlerExW"
Const _FuncName_StartServiceCtrlDispatcher = "StartServiceCtrlDispatcherW"
Const _FuncName_StartService = "StartServiceW"
Const _FuncName_NotifyServiceStatusChange = "NotifyServiceStatusChangeW"
Const _FuncName_ControlServiceEx = "ControlServiceExW"
#else
Const _FuncName_ChangeServiceConfig = "ChangeServiceConfigA"
Const _FuncName_ChangeServiceConfig2 = "ChangeServiceConfig2A"
Const _FuncName_CreateService = "CreateServiceA"
Const _FuncName_EnumDependentServices = "EnumDependentServicesA"
Const _FuncName_EnumServicesStatus = "EnumServicesStatusA"
Const _FuncName_EnumServicesStatusEx = "EnumServicesStatusExA"
Const _FuncName_GetServiceKeyName = "GetServiceKeyNameA"
Const _FuncName_GetServiceDisplayName = "GetServiceDisplayNameA"
Const _FuncName_OpenSCManager = "OpenSCManagerA"
Const _FuncName_OpenService = "OpenServiceA"
Const _FuncName_QueryServiceConfig = "QueryServiceConfigA"
Const _FuncName_QueryServiceConfig2 = "QueryServiceConfig2A"
Const _FuncName_QueryServiceLockStatus = "QueryServiceLockStatusA"
Const _FuncName_RegisterServiceCtrlHandler = "RegisterServiceCtrlHandlerA"
Const _FuncName_RegisterServiceCtrlHandlerEx = "RegisterServiceCtrlHandlerExA"
Const _FuncName_StartServiceCtrlDispatcher = "StartServiceCtrlDispatcherA"
Const _FuncName_StartService = "StartServiceA"
Const _FuncName_NotifyServiceStatusChange = "NotifyServiceStatusChangeA"
Const _FuncName_ControlServiceEx = "ControlServiceExA"
#endif

Const SERVICES_ACTIVE_DATABASE = "ServicesActive"
Const SERVICES_FAILED_DATABASE = "ServicesFailed"

Const SC_GROUP_IDENTIFIER = "+"

Const SERVICE_NO_CHANGE = &hffffffff

Const SERVICE_ACTIVE = &h00000001
Const SERVICE_INACTIVE = &h00000002
Const SERVICE_STATE_ALL = (SERVICE_ACTIVE Or SERVICE_INACTIVE)

Const SERVICE_CONTROL_STOP = &h00000001
Const SERVICE_CONTROL_PAUSE = &h00000002
Const SERVICE_CONTROL_CONTINUE = &h00000003
Const SERVICE_CONTROL_INTERROGATE = &h00000004
Const SERVICE_CONTROL_SHUTDOWN = &h00000005
Const SERVICE_CONTROL_PARAMCHANGE = &h00000006
Const SERVICE_CONTROL_NETBINDADD = &h00000007
Const SERVICE_CONTROL_NETBINDREMOVE = &h00000008
Const SERVICE_CONTROL_NETBINDENABLE = &h00000009
Const SERVICE_CONTROL_NETBINDDISABLE = &h0000000A
Const SERVICE_CONTROL_DEVICEEVENT = &h0000000B
Const SERVICE_CONTROL_HARDWAREPROFILECHANGE = &h0000000C
Const SERVICE_CONTROL_POWEREVENT = &h0000000D
Const SERVICE_CONTROL_SESSIONCHANGE = &h0000000E
Const SERVICE_CONTROL_PRESHUTDOWN = &h0000000F

Const SERVICE_STOPPED = &h00000001
Const SERVICE_START_PENDING = &h00000002
Const SERVICE_STOP_PENDING = &h00000003
Const SERVICE_RUNNING = &h00000004
Const SERVICE_CONTINUE_PENDING = &h00000005
Const SERVICE_PAUSE_PENDING = &h00000006
Const SERVICE_PAUSED = &h00000007

Const SERVICE_ACCEPT_STOP = &h00000001
Const SERVICE_ACCEPT_PAUSE_CONTINUE = &h00000002
Const SERVICE_ACCEPT_SHUTDOWN = &h00000004
Const SERVICE_ACCEPT_PARAMCHANGE = &h00000008
Const SERVICE_ACCEPT_NETBINDCHANGE = &h00000010
Const SERVICE_ACCEPT_HARDWAREPROFILECHANGE = &h00000020
Const SERVICE_ACCEPT_POWEREVENT = &h00000040
Const SERVICE_ACCEPT_SESSIONCHANGE = &h00000080
Const SERVICE_ACCEPT_PRESHUTDOWN = &h00000100

Const SC_MANAGER_CONNECT = &h0001
Const SC_MANAGER_CREATE_SERVICE = &h0002
Const SC_MANAGER_ENUMERATE_SERVICE = &h0004
Const SC_MANAGER_LOCK = &h0008
Const SC_MANAGER_QUERY_LOCK_STATUS = &h0010
Const SC_MANAGER_MODIFY_BOOT_CONFIG = &h0020

Const SC_MANAGER_ALL_ACCESS = (
	STANDARD_RIGHTS_REQUIRED Or _
	SC_MANAGER_CONNECT Or _
	SC_MANAGER_CREATE_SERVICE Or _
	SC_MANAGER_ENUMERATE_SERVICE Or _
	SC_MANAGER_LOCK Or _
	SC_MANAGER_QUERY_LOCK_STATUS Or _
	SC_MANAGER_MODIFY_BOOT_CONFIG)

Const SERVICE_QUERY_CONFIG = &h0001
Const SERVICE_CHANGE_CONFIG = &h0002
Const SERVICE_QUERY_STATUS = &h0004
Const SERVICE_ENUMERATE_DEPENDENTS = &h0008
Const SERVICE_START = &h0010
Const SERVICE_STOP = &h0020
Const SERVICE_PAUSE_CONTINUE = &h0040
Const SERVICE_INTERROGATE = &h0080
Const SERVICE_USER_DEFINED_CONTROL = &h0100

Const SERVICE_ALL_ACCESS = (
	STANDARD_RIGHTS_REQUIRED Or _
	SERVICE_QUERY_CONFIG Or _
	SERVICE_CHANGE_CONFIG Or _
	SERVICE_QUERY_STATUS Or _
	SERVICE_ENUMERATE_DEPENDENTS Or _
	SERVICE_START Or _
	SERVICE_STOP Or _
	SERVICE_PAUSE_CONTINUE Or _
	SERVICE_INTERROGATE Or _
	SERVICE_USER_DEFINED_CONTROL)

Const SERVICE_RUNS_IN_SYSTEM_PROCESS = &h00000001

Const SERVICE_CONFIG_DESCRIPTION = 1
Const SERVICE_CONFIG_FAILURE_ACTIONS = 2
Const SERVICE_CONFIG_DELAYED_AUTO_START_INFO = 3
Const SERVICE_CONFIG_FAILURE_ACTIONS_FLAG = 4
Const SERVICE_CONFIG_SERVICE_SID_INFO = 5
Const SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO = 6
Const SERVICE_CONFIG_PRESHUTDOWN_INFO = 7

Const SERVICE_NOTIFY_STATUS_CHANGE_1 = 1
Const SERVICE_NOTIFY_STATUS_CHANGE_2 = 2

Const SERVICE_NOTIFY_STATUS_CHANGE = SERVICE_NOTIFY_STATUS_CHANGE_2

Const SERVICE_NOTIFY_STOPPED = &h00000001
Const SERVICE_NOTIFY_START_PENDING = &h00000002
Const SERVICE_NOTIFY_STOP_PENDING = &h00000004
Const SERVICE_NOTIFY_RUNNING = &h00000008
Const SERVICE_NOTIFY_CONTINUE_PENDING = &h00000010
Const SERVICE_NOTIFY_PAUSE_PENDING = &h00000020
Const SERVICE_NOTIFY_PAUSED = &h00000040
Const SERVICE_NOTIFY_CREATED = &h00000080
Const SERVICE_NOTIFY_DELETED = &h00000100
Const SERVICE_NOTIFY_DELETE_PENDING = &h00000200

Const SERVICE_STOP_REASON_FLAG_MIN = &h00000000
Const SERVICE_STOP_REASON_FLAG_UNPLANNED = &h10000000
Const SERVICE_STOP_REASON_FLAG_CUSTOM = &h20000000
Const SERVICE_STOP_REASON_FLAG_PLANNED = &h40000000
Const SERVICE_STOP_REASON_FLAG_MAX = &h80000000

Const SERVICE_STOP_REASON_MAJOR_MIN = &h00000000
Const SERVICE_STOP_REASON_MAJOR_OTHER = &h00010000
Const SERVICE_STOP_REASON_MAJOR_HARDWARE = &h00020000
Const SERVICE_STOP_REASON_MAJOR_OPERATINGSYSTEM = &h00030000
Const SERVICE_STOP_REASON_MAJOR_SOFTWARE = &h00040000
Const SERVICE_STOP_REASON_MAJOR_APPLICATION = &h00050000
Const SERVICE_STOP_REASON_MAJOR_NONE = &h00060000
Const SERVICE_STOP_REASON_MAJOR_MAX = &h00070000
Const SERVICE_STOP_REASON_MAJOR_MIN_CUSTOM = &h00400000
Const SERVICE_STOP_REASON_MAJOR_MAX_CUSTOM = &h00ff0000

Const SERVICE_STOP_REASON_MINOR_MIN = &h00000000
Const SERVICE_STOP_REASON_MINOR_OTHER = &h00000001
Const SERVICE_STOP_REASON_MINOR_MAINTENANCE = &h00000002
Const SERVICE_STOP_REASON_MINOR_INSTALLATION = &h00000003
Const SERVICE_STOP_REASON_MINOR_UPGRADE = &h00000004
Const SERVICE_STOP_REASON_MINOR_RECONFIG = &h00000005
Const SERVICE_STOP_REASON_MINOR_HUNG = &h00000006
Const SERVICE_STOP_REASON_MINOR_UNSTABLE = &h00000007
Const SERVICE_STOP_REASON_MINOR_DISK = &h00000008
Const SERVICE_STOP_REASON_MINOR_NETWORKCARD = &h00000009
Const SERVICE_STOP_REASON_MINOR_ENVIRONMENT = &h0000000a
Const SERVICE_STOP_REASON_MINOR_HARDWARE_DRIVER = &h0000000b
Const SERVICE_STOP_REASON_MINOR_OTHERDRIVER = &h0000000c
Const SERVICE_STOP_REASON_MINOR_SERVICEPACK = &h0000000d
Const SERVICE_STOP_REASON_MINOR_SOFTWARE_UPDATE = &h0000000e
Const SERVICE_STOP_REASON_MINOR_SECURITYFIX = &h0000000f
Const SERVICE_STOP_REASON_MINOR_SECURITY = &h00000010
Const SERVICE_STOP_REASON_MINOR_NETWORK_CONNECTIVITY = &h00000011
Const SERVICE_STOP_REASON_MINOR_WMI = &h00000012
Const SERVICE_STOP_REASON_MINOR_SERVICEPACK_UNINSTALL = &h00000013
Const SERVICE_STOP_REASON_MINOR_SOFTWARE_UPDATE_UNINSTALL = &h00000014
Const SERVICE_STOP_REASON_MINOR_SECURITYFIX_UNINSTALL = &h00000015
Const SERVICE_STOP_REASON_MINOR_MMC = &h00000016
Const SERVICE_STOP_REASON_MINOR_NONE = &h00000017
Const SERVICE_STOP_REASON_MINOR_MAX = &h00000018
Const SERVICE_STOP_REASON_MINOR_MIN_CUSTOM = &h00000100
Const SERVICE_STOP_REASON_MINOR_MAX_CUSTOM = &h0000FFFF

Const SERVICE_CONTROL_STATUS_REASON_INFO = 1

Const SERVICE_SID_TYPE_NONE = &h00000000
Const SERVICE_SID_TYPE_UNRESTRICTED = &h00000001
Const SERVICE_SID_TYPE_RESTRICTED = (&h00000002 Or SERVICE_SID_TYPE_UNRESTRICTED)

Type SERVICE_DESCRIPTION
	lpDescription As LPTSTR
End Type
/*
Const Enum SC_ACTION_TYPE
	SC_ACTION_NONE = 0
	SC_ACTION_RESTART = 1
	SC_ACTION_REBOOT = 2
	SC_ACTION_RUN_COMMAND = 3
End Type
*/
TypeDef SC_ACTION_TYPE = DWord
Const SC_ACTION_NONE = 0
Const SC_ACTION_RESTART = 1
Const SC_ACTION_REBOOT = 2
Const SC_ACTION_RUN_COMMAND = 3

Type SC_ACTION
	Type_ As SC_ACTION_TYPE
	Delay As DWord
End Type

Type SERVICE_FAILURE_ACTIONS
	dwResetPeriod As DWord
	lpRebootMsg As LPTSTR
	lpCommand As LPTSTR
	/*[range(0, 1024)]*/ cActions As DWord
	/*[size_is(cActions)]*/ lpsaActions As *SC_ACTION
End Type

Type SERVICE_DELAYED_AUTO_START_INFO
	fDelayedAutostart As BOOL
End Type

Type SERVICE_FAILURE_ACTIONS_FLAG
	fFailureActionsOnNonCrashFailures As BOOL
End Type

Type SERVICE_SID_INFO
	dwServiceSidType As DWord
End Type

Type _SERVICE_REQUIRED_PRIVILEGES_INFO
	pmszRequiredPrivileges As LPTSTR
End Type

Type SERVICE_PRESHUTDOWN_INFO
	dwPreshutdownTimeout As DWord
End Type

Type _System_DeclareHandle_SC_HANDLE:unused As DWord:End Type
TypeDef SC_HANDLE = *_System_DeclareHandle_SC_HANDLE

Type _System_DeclareHandle_SERVICE_STATUS_HANDLE:unused As DWord:End Type
TypeDef SERVICE_STATUS_HANDLE = *_System_DeclareHandle_SERVICE_STATUS_HANDLE

Const Enum SC_STATUS_TYPE
	SC_STATUS_PROCESS_INFO = 0
End Enum

Const Enum SC_ENUM_TYPE
	SC_ENUM_PROCESS_INFO = 0
End Enum

Type SERVICE_STATUS
	dwServiceType As DWord
	dwCurrentState As DWord
	dwControlsAccepted As DWord
	dwWin32ExitCode As DWord
	dwServiceSpecificExitCode As DWord
	dwCheckPoint As DWord
	dwWaitHint As DWord
End Type

Type SERVICE_STATUS_PROCESS
	dwServiceType As DWord
	dwCurrentState As DWord
	dwControlsAccepted As DWord
	dwWin32ExitCode As DWord
	dwServiceSpecificExitCode As DWord
	dwCheckPoint As DWord
	dwWaitHint As DWord
	dwProcessId As DWord
	dwServiceFlags As DWord
End Type

Type ENUM_SERVICE_STATUS
	lpServiceName As LPTSTR
	lpDisplayName As LPTSTR
	ServiceStatus As SERVICE_STATUS
End Type

Type ENUM_SERVICE_STATUS_PROCESS
	lpServiceName As LPTSTR
	lpDisplayName As LPTSTR
	ServiceStatusProcess As SERVICE_STATUS_PROCESS
End Type

TypeDef SC_LOCK = VoidPtr

Type QUERY_SERVICE_LOCK_STATUS
	fIsLocked As DWord
	lpLockOwner As LPTSTR
	dwLockDuration As DWord
End Type

Type QUERY_SERVICE_CONFIG
	dwServiceType As DWord
	dwStartType As DWord
	dwErrorControl As DWord
	lpBinaryPathName As LPTSTR
	lpLoadOrderGroup As LPTSTR
	dwTagId As DWord
	lpDependencies As LPTSTR
	lpServiceStartName As LPTSTR
	lpDisplayName As LPTSTR
End Type

TypeDef LPSERVICE_MAIN_FUNCTION = *Sub(dwNumServicesArgs As DWord, lpServiceArgVectors As *LPTSTR)

Type SERVICE_TABLE_ENTRY
	lpServiceName As LPTSTR
	lpServiceProc As LPSERVICE_MAIN_FUNCTION
End Type

TypeDef LPHANDLER_FUNCTION = *Sub(dwControl As DWord)

TypeDef LPHANDLER_FUNCTION_EX = *Function(dwControl As DWord, dwEventType As DWord, lpEventData As VoidPtr, lpContext As VoidPtr) As DWord

TypeDef PFN_SC_NOTIFY_CALLBACK = *Sub(pParameter As VoidPtr)

Type SERVICE_NOTIFY_1
	dwVersion As DWord
	pfnNotifyCallback As PFN_SC_NOTIFY_CALLBACK
	pContext As VoidPtr
	dwNotificationStatus As DWord
	ServiceStatus As SERVICE_STATUS_PROCESS
End Type

Type SERVICE_NOTIFY_2
	dwVersion As DWord
	pfnNotifyCallback As PFN_SC_NOTIFY_CALLBACK
	pContext As VoidPtr
	dwNotificationStatus As DWord
	ServiceStatus As SERVICE_STATUS_PROCESS
	dwNotificationTriggered As DWord
	pszServiceNames As LPTSTR
End Type

TypeDef SERVICE_NOTIFY = SERVICE_NOTIFY_2

Type SERVICE_CONTROL_STATUS_REASON_PARAMS
	dwReason As DWord
	pszComment As LPTSTR
	ServiceStatus As SERVICE_STATUS_PROCESS
End Type

Declare Function ChangeServiceConfig Lib "advapi32" Alias _FuncName_ChangeServiceConfig (
	/*__in*/ hService As SC_HANDLE,
	/*__in*/ dwServiceType As DWord,
	/*__in*/ dwStartType As DWord,
	/*__in*/ dwErrorControl As DWord,
	/*__in_opt*/ lpBinaryPathName As LPCTSTR,
	/*__in_opt*/ lpLoadOrderGroup As LPCTSTR,
	/*__out_opt*/ lpdwTagId As *DWord,
	/*__in_opt*/ lpDependencies As LPCTSTR,
	/*__in_opt*/ lpServiceStartName As LPCTSTR,
	/*__in_opt*/ lpPassword As LPCTSTR,
	/*__in_opt*/ lpDisplayName As LPCTSTR
) As BOOL

Declare Function ChangeServiceConfig2 Lib "advapi32" Alias _FuncName_ChangeServiceConfig2 (
	/*__in*/ hService As SC_HANDLE,
	/*__in*/ dwInfoLevel As DWord,
	/*__in_opt*/ lpInfo As VoidPtr
) As BOOL

Declare Function CloseServiceHandle Lib "advapi32" (
	/*__in*/ hSCObject As SC_HANDLE
) As BOOL

Declare Function ControlService Lib "advapi32" (
	/*__in*/ hService As SC_HANDLE,
	/*__in*/ dwControl As DWord,
	/*__out*/ ByRef ServiceStatus As SERVICE_STATUS
) As BOOL

Declare Function CreateService Lib "advapi32" Alias _FuncName_CreateService (
	/*__in*/ hSCManager As SC_HANDLE,
	/*__in*/ lpServiceName As LPCTSTR,
	/*__in_opt*/ lpDisplayName As LPCTSTR,
	/*__in*/ dwDesiredAccess As DWord,
	/*__in*/ dwServiceType As DWord,
	/*__in*/ dwStartType As DWord,
	/*__in*/ dwErrorControl As DWord,
	/*__in_opt*/ lpBinaryPathName As LPCTSTR,
	/*__in_opt*/ lpLoadOrderGroup As LPCTSTR,
	/*__out_opt*/ lpdwTagId As *DWord,
	/*__in_opt*/ lpDependencies As LPCTSTR,
	/*__in_opt*/ lpServiceStartName As LPCTSTR,
	/*__in_opt*/ lpPassword As LPCTSTR
) As SC_HANDLE

Declare Function DeleteService Lib "advapi32" (
	/*__in*/ hService As SC_HANDLE
) As BOOL

Declare Function EnumDependentServices Lib "advapi32" Alias _FuncName_EnumDependentServices (
	/*__in*/ hService As SC_HANDLE,
	/*__in*/ dwServiceState As DWord,
	/*__out_bcount_opt(cbBufSize)*/ lpServices As *ENUM_SERVICE_STATUS,
	/*__in*/ cbBufSize As DWord,
	/*__out*/ pcbBytesNeeded As *DWord,
	/*__out*/ lpServicesReturned As *DWord
) As BOOL

Declare Function EnumServicesStatus Lib "advapi32" Alias _FuncName_EnumServicesStatus (
	/*__in*/ hSCManager As SC_HANDLE,
	/*__in*/ dwServiceType As DWord,
	/*__in*/ dwServiceState As DWord,
	/*__out_bcount_opt(cbBufSize)*/ lpServices As *ENUM_SERVICE_STATUS,
	/*__in*/ cbBufSize As DWord,
	/*__out*/ pcbBytesNeeded As *DWord,
	/*__out*/ lpServicesReturned As *DWord,
	/*__inout_opt*/ lpResumeHandle As *DWord
) As BOOL

Declare Function EnumServicesStatusEx Lib "advapi32" Alias _FuncName_EnumServicesStatusEx (
	/*__in*/ hSCManager As SC_HANDLE,
	/*__in*/ InfoLevel As SC_ENUM_TYPE,
	/*__in*/ dwServiceType As DWord,
	/*__in*/ dwServiceState As DWord,
	/*__out_bcount_opt(cbBufSize)*/ lpServices As *Byte,
	/*__in*/ cbBufSize As DWord,
	/*__out*/ pcbBytesNeeded As *DWord,
	/*__out*/ lpServicesReturned As *DWord,
	/*__inout_opt*/ lpResumeHandle As *DWord,
	/*__in_opt*/ pszGroupName As LPCTSTR
) As BOOL

Declare Function GetServiceKeyName Lib "advapi32" Alias _FuncName_GetServiceKeyName (
	/*__in*/ hSCManager As SC_HANDLE,
	/*__in*/ lpDisplayName As LPCTSTR,
	/*__out_ecount_opt(*lpcchBuffer)*/ lpServiceName As LPTSTR,
	/*__inout*/ lpcchBuffer As *DWord
) As BOOL

Declare Function GetServiceDisplayName Lib "advapi32" Alias _FuncName_GetServiceDisplayName (
	/*__in*/ hSCManager As SC_HANDLE,
	/*__in*/ lpServiceName As LPCTSTR,
	/*__out_ecount_opt(*lpcchBuffer)*/ lpDisplayName As LPTSTR,
	/*__inout*/ lpcchBuffer As *DWord
) As BOOL

Declare Function LockServiceDatabase Lib "advapi32" (
	/*__in*/ hSCManager As SC_HANDLE
) As SC_LOCK

Declare Function NotifyBootConfigStatus Lib "advapi32" (
	/*__in*/ BootAcceptable As BOOL
) As BOOL

Declare Function OpenSCManager Lib "advapi32" Alias _FuncName_OpenSCManager (
	/*__in_opt*/ lpMachineName As LPCTSTR,
	/*__in_opt*/ lpDatabaseName As LPCTSTR,
	/*__in*/ dwDesiredAccess As DWord
) As SC_HANDLE

Declare Function OpenService Lib "advapi32" Alias _FuncName_OpenService (
	/*__in*/ hSCManager As SC_HANDLE,
	/*__in*/ lpServiceName As LPCTSTR,
	/*__in*/ dwDesiredAccess As DWord
) As SC_HANDLE

Declare Function QueryServiceConfig Lib "advapi32" Alias _FuncName_QueryServiceConfig (
	/*__in*/ hService As SC_HANDLE,
	/*__out_bcount_opt(cbBufSize)*/ lpServiceConfig As *QUERY_SERVICE_CONFIG,
	/*__in*/ cbBufSize As DWord,
	/*__out*/ pcbBytesNeeded As *DWord
) As BOOL

Declare Function QueryServiceConfig2 Lib "advapi32" Alias _FuncName_QueryServiceConfig2 (
	/*__in*/ hService As SC_HANDLE,
	/*__in*/ dwInfoLevel As DWord,
	/*__out_bcount_opt(cbBufSize)*/ lpBuffer As *Byte,
	/*__in*/ cbBufSize As DWord,
	/*__out*/ pcbBytesNeeded As *DWord
) As BOOL

Declare Function QueryServiceLockStatus Lib "advapi32" Alias _FuncName_QueryServiceLockStatus (
	/*__in*/ hSCManager As SC_HANDLE,
	/*__out_bcount_opt(cbBufSize)*/ lpLockStatus As *QUERY_SERVICE_LOCK_STATUS,
	/*__in*/ cbBufSize As DWord,
	/*__out*/ pcbBytesNeeded As *DWord
) As BOOL

Declare Function QueryServiceObjectSecurity Lib "advapi32" (
	/*__in*/ hService As SC_HANDLE,
	/*__in*/ dwSecurityInformation As SECURITY_INFORMATION,
	/*__out_bcount_opt(cbBufSize)*/ lpSecurityDescriptor As *SECURITY_DESCRIPTOR,
	/*__in*/ cbBufSize As DWord,
	/*__out*/ pcbBytesNeeded As *DWord
) As BOOL

Declare Function QueryServiceStatus Lib "advapi32" (
	/*__in*/ hService As SC_HANDLE,
	/*__out*/ ByRef ServiceStatus As SERVICE_STATUS
) As BOOL

Declare Function QueryServiceStatusEx Lib "advapi32" (
	/*__in*/ hService As SC_HANDLE,
	/*__in*/ InfoLevel As SC_STATUS_TYPE,
	/*__out_bcount_opt(cbBufSize)*/ lpBuffer As *Byte,
	/*__in*/ cbBufSize As DWord,
	/*__out*/ ByRef cbBytesNeeded As DWord
) As BOOL

Declare Function RegisterServiceCtrlHandler Lib "advapi32" Alias _FuncName_RegisterServiceCtrlHandler (
	/*__in*/ lpServiceName As LPCTSTR,
	/*__in __callback*/ lpHandlerProc As LPHANDLER_FUNCTION
) As SERVICE_STATUS_HANDLE

Declare Function RegisterServiceCtrlHandlerEx Lib "advapi32" Alias _FuncName_RegisterServiceCtrlHandlerEx (
	/*__in*/ lpServiceName As LPCTSTR,
	/*__in __callback*/ lpHandlerProc As LPHANDLER_FUNCTION_EX,
	/*__in_opt*/ lpContext As VoidPtr
) As SERVICE_STATUS_HANDLE

Declare Function SetServiceObjectSecurity Lib "advapi32" (
	/*__in*/ hService As SC_HANDLE,
	/*__in*/ dwSecurityInformation As SECURITY_INFORMATION,
	/*__in*/ lpSecurityDescriptor As *SECURITY_DESCRIPTOR
) As BOOL

Declare Function SetServiceStatus Lib "advapi32" (
	/*__in*/ hServiceStatus As SERVICE_STATUS_HANDLE,
	/*__in*/ ByRef ServiceStatus As SERVICE_STATUS
) As BOOL

Declare Function StartServiceCtrlDispatcher Lib "advapi32" Alias _FuncName_StartServiceCtrlDispatcher (
	/*__in CONST*/ lpServiceStartTable As *SERVICE_TABLE_ENTRY,
) As BOOL

Declare Function StartService Lib "advapi32" Alias _FuncName_StartService (
	/*__in*/ hService As SC_HANDLE,
	/*__in*/ dwNumServiceArgs As DWord,
	/*__in_ecount_opt(dwNumServiceArgs)*/ lpServiceArgVectors As *LPCTSTR,
) As BOOL

Declare Function UnlockServiceDatabase Lib "advapi32" (
	/*__in*/ ScLock As SC_LOCK
) As BOOL

Declare Function NotifyServiceStatusChange Lib "advapi32" Alias _FuncName_NotifyServiceStatusChange (
	/*__in*/ hService As SC_HANDLE,
	/*__in*/ dwNotifyMask As DWord,
	/*__in*/ ByRef NotifyBuffer As SERVICE_NOTIFY
) As DWord

Declare Function ControlServiceEx Lib "advapi32" Alias _FuncName_ControlServiceEx (
	/*__in*/ hService As SC_HANDLE,
	/*__in*/ dwControl As DWord,
	/*__in*/ dwInfoLevel As DWord,
	/*__inout*/ pControlParams As VoidPtr
) As BOOL
