|
|
/*++ BUILD Version: 0010 // Increment this if a change has global effects
Copyright (c) 1995 Microsoft Corporation
Module Name:
winsvc.h
Abstract:
Header file for the Service Control Manager
Environment:
User Mode - Win32
--*/ #ifndef _WINSVC_
#define _WINSVC_
//
// Define API decoration for direct importing of DLL references.
//
#if !defined(WINADVAPI)
#if !defined(_ADVAPI32_)
#define WINADVAPI DECLSPEC_IMPORT
#else
#define WINADVAPI
#endif
#endif
#ifdef __cplusplus
extern "C" { #endif
//
// Constants
//
//
// Service database names
//
#define SERVICES_ACTIVE_DATABASEW L"ServicesActive"
#define SERVICES_FAILED_DATABASEW L"ServicesFailed"
#define SERVICES_ACTIVE_DATABASEA "ServicesActive"
#define SERVICES_FAILED_DATABASEA "ServicesFailed"
//
// Character to designate that a name is a group
//
#define SC_GROUP_IDENTIFIERW L'+'
#define SC_GROUP_IDENTIFIERA '+'
#ifdef UNICODE
#define SERVICES_ACTIVE_DATABASE SERVICES_ACTIVE_DATABASEW
#define SERVICES_FAILED_DATABASE SERVICES_FAILED_DATABASEW
#define SC_GROUP_IDENTIFIER SC_GROUP_IDENTIFIERW
#else // ndef UNICODE
#define SERVICES_ACTIVE_DATABASE SERVICES_ACTIVE_DATABASEA
#define SERVICES_FAILED_DATABASE SERVICES_FAILED_DATABASEA
#define SC_GROUP_IDENTIFIER SC_GROUP_IDENTIFIERA
#endif // ndef UNICODE
//
// Value to indicate no change to an optional parameter
//
#define SERVICE_NO_CHANGE 0xffffffff
//
// Service State -- for Enum Requests (Bit Mask)
//
#define SERVICE_ACTIVE 0x00000001
#define SERVICE_INACTIVE 0x00000002
#define SERVICE_STATE_ALL (SERVICE_ACTIVE | \
SERVICE_INACTIVE)
//
// Controls
//
#define SERVICE_CONTROL_STOP 0x00000001
#define SERVICE_CONTROL_PAUSE 0x00000002
#define SERVICE_CONTROL_CONTINUE 0x00000003
#define SERVICE_CONTROL_INTERROGATE 0x00000004
#define SERVICE_CONTROL_SHUTDOWN 0x00000005
//
// Service State -- for CurrentState
//
#define SERVICE_STOPPED 0x00000001
#define SERVICE_START_PENDING 0x00000002
#define SERVICE_STOP_PENDING 0x00000003
#define SERVICE_RUNNING 0x00000004
#define SERVICE_CONTINUE_PENDING 0x00000005
#define SERVICE_PAUSE_PENDING 0x00000006
#define SERVICE_PAUSED 0x00000007
//
// Controls Accepted (Bit Mask)
//
#define SERVICE_ACCEPT_STOP 0x00000001
#define SERVICE_ACCEPT_PAUSE_CONTINUE 0x00000002
#define SERVICE_ACCEPT_SHUTDOWN 0x00000004
//
// Service Control Manager object specific access types
//
#define SC_MANAGER_CONNECT 0x0001
#define SC_MANAGER_CREATE_SERVICE 0x0002
#define SC_MANAGER_ENUMERATE_SERVICE 0x0004
#define SC_MANAGER_LOCK 0x0008
#define SC_MANAGER_QUERY_LOCK_STATUS 0x0010
#define SC_MANAGER_MODIFY_BOOT_CONFIG 0x0020
#define SC_MANAGER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \
SC_MANAGER_CONNECT | \ SC_MANAGER_CREATE_SERVICE | \ SC_MANAGER_ENUMERATE_SERVICE | \ SC_MANAGER_LOCK | \ SC_MANAGER_QUERY_LOCK_STATUS | \ SC_MANAGER_MODIFY_BOOT_CONFIG)
//
// Service object specific access type
//
#define SERVICE_QUERY_CONFIG 0x0001
#define SERVICE_CHANGE_CONFIG 0x0002
#define SERVICE_QUERY_STATUS 0x0004
#define SERVICE_ENUMERATE_DEPENDENTS 0x0008
#define SERVICE_START 0x0010
#define SERVICE_STOP 0x0020
#define SERVICE_PAUSE_CONTINUE 0x0040
#define SERVICE_INTERROGATE 0x0080
#define SERVICE_USER_DEFINED_CONTROL 0x0100
#define SERVICE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \
SERVICE_QUERY_CONFIG | \ SERVICE_CHANGE_CONFIG | \ SERVICE_QUERY_STATUS | \ SERVICE_ENUMERATE_DEPENDENTS | \ SERVICE_START | \ SERVICE_STOP | \ SERVICE_PAUSE_CONTINUE | \ SERVICE_INTERROGATE | \ SERVICE_USER_DEFINED_CONTROL)
//
// Handle Types
//
typedef HANDLE SC_HANDLE; typedef SC_HANDLE *LPSC_HANDLE;
typedef DWORD SERVICE_STATUS_HANDLE;
//
// Service Status Structure
//
typedef struct _SERVICE_STATUS { DWORD dwServiceType; DWORD dwCurrentState; DWORD dwControlsAccepted; DWORD dwWin32ExitCode; DWORD dwServiceSpecificExitCode; DWORD dwCheckPoint; DWORD dwWaitHint; } SERVICE_STATUS, *LPSERVICE_STATUS;
//
// Service Status Enumeration Structure
//
#ifndef UNICODE_ONLY
typedef struct _ENUM_SERVICE_STATUSA { LPSTR lpServiceName; LPSTR lpDisplayName; SERVICE_STATUS ServiceStatus; } ENUM_SERVICE_STATUSA, *LPENUM_SERVICE_STATUSA; #endif //!UNICODE_ONLY
#ifndef ANSI_ONLY
typedef struct _ENUM_SERVICE_STATUSW { LPWSTR lpServiceName; LPWSTR lpDisplayName; SERVICE_STATUS ServiceStatus; } ENUM_SERVICE_STATUSW, *LPENUM_SERVICE_STATUSW; #endif //!ANSI_ONLY
#ifdef UNICODE
typedef ENUM_SERVICE_STATUSW ENUM_SERVICE_STATUS; typedef LPENUM_SERVICE_STATUSW LPENUM_SERVICE_STATUS; #else
typedef ENUM_SERVICE_STATUSA ENUM_SERVICE_STATUS; typedef LPENUM_SERVICE_STATUSA LPENUM_SERVICE_STATUS; #endif // UNICODE
//
// Structures for the Lock API functions
//
typedef LPVOID SC_LOCK;
#ifndef UNICODE_ONLY
typedef struct _QUERY_SERVICE_LOCK_STATUSA { DWORD fIsLocked; LPSTR lpLockOwner; DWORD dwLockDuration; } QUERY_SERVICE_LOCK_STATUSA, *LPQUERY_SERVICE_LOCK_STATUSA; #endif //!UNICODE_ONLY
#ifndef ANSI_ONLY
typedef struct _QUERY_SERVICE_LOCK_STATUSW { DWORD fIsLocked; LPWSTR lpLockOwner; DWORD dwLockDuration; } QUERY_SERVICE_LOCK_STATUSW, *LPQUERY_SERVICE_LOCK_STATUSW; #endif //!ANSI_ONLY
#ifdef UNICODE
typedef QUERY_SERVICE_LOCK_STATUSW QUERY_SERVICE_LOCK_STATUS; typedef LPQUERY_SERVICE_LOCK_STATUSW LPQUERY_SERVICE_LOCK_STATUS; #else
typedef QUERY_SERVICE_LOCK_STATUSA QUERY_SERVICE_LOCK_STATUS; typedef LPQUERY_SERVICE_LOCK_STATUSA LPQUERY_SERVICE_LOCK_STATUS; #endif // UNICODE
//
// Query Service Configuration Structure
//
#ifndef UNICODE_ONLY
typedef struct _QUERY_SERVICE_CONFIGA { DWORD dwServiceType; DWORD dwStartType; DWORD dwErrorControl; LPSTR lpBinaryPathName; LPSTR lpLoadOrderGroup; DWORD dwTagId; LPSTR lpDependencies; LPSTR lpServiceStartName; LPSTR lpDisplayName; } QUERY_SERVICE_CONFIGA, *LPQUERY_SERVICE_CONFIGA; #endif //!UNICODE_ONLY
#ifndef ANSI_ONLY
typedef struct _QUERY_SERVICE_CONFIGW { DWORD dwServiceType; DWORD dwStartType; DWORD dwErrorControl; LPWSTR lpBinaryPathName; LPWSTR lpLoadOrderGroup; DWORD dwTagId; LPWSTR lpDependencies; LPWSTR lpServiceStartName; LPWSTR lpDisplayName; } QUERY_SERVICE_CONFIGW, *LPQUERY_SERVICE_CONFIGW; #endif //!ANSI_ONLY
#ifdef UNICODE
typedef QUERY_SERVICE_CONFIGW QUERY_SERVICE_CONFIG; typedef LPQUERY_SERVICE_CONFIGW LPQUERY_SERVICE_CONFIG; #else
typedef QUERY_SERVICE_CONFIGA QUERY_SERVICE_CONFIG; typedef LPQUERY_SERVICE_CONFIGA LPQUERY_SERVICE_CONFIG; #endif // UNICODE
//
// Function Prototype for the Service Main Function
//
#ifndef ANSI_ONLY
typedef VOID (WINAPI *LPSERVICE_MAIN_FUNCTIONW)( DWORD dwNumServicesArgs, LPWSTR *lpServiceArgVectors ); #endif //!ANSI_ONLY
#ifndef UNICODE_ONLY
typedef VOID (WINAPI *LPSERVICE_MAIN_FUNCTIONA)( DWORD dwNumServicesArgs, LPSTR *lpServiceArgVectors ); #endif //!UNICODE_ONLY
#ifdef UNICODE
#define LPSERVICE_MAIN_FUNCTION LPSERVICE_MAIN_FUNCTIONW
#else
#define LPSERVICE_MAIN_FUNCTION LPSERVICE_MAIN_FUNCTIONA
#endif //UNICODE
//
// Service Start Table
//
#ifndef UNICODE_ONLY
typedef struct _SERVICE_TABLE_ENTRYA { LPSTR lpServiceName; LPSERVICE_MAIN_FUNCTIONA lpServiceProc; }SERVICE_TABLE_ENTRYA, *LPSERVICE_TABLE_ENTRYA; #endif //!UNICODE_ONLY
#ifndef ANSI_ONLY
typedef struct _SERVICE_TABLE_ENTRYW { LPWSTR lpServiceName; LPSERVICE_MAIN_FUNCTIONW lpServiceProc; }SERVICE_TABLE_ENTRYW, *LPSERVICE_TABLE_ENTRYW; #endif //!ANSI_ONLY
#ifdef UNICODE
typedef SERVICE_TABLE_ENTRYW SERVICE_TABLE_ENTRY; typedef LPSERVICE_TABLE_ENTRYW LPSERVICE_TABLE_ENTRY; #else
typedef SERVICE_TABLE_ENTRYA SERVICE_TABLE_ENTRY; typedef LPSERVICE_TABLE_ENTRYA LPSERVICE_TABLE_ENTRY; #endif // UNICODE
//
// Prototype for the Service Control Handler Function
//
typedef VOID (WINAPI *LPHANDLER_FUNCTION)( DWORD dwControl );
///////////////////////////////////////////////////////////////////////////
// API Function Prototypes
///////////////////////////////////////////////////////////////////////////
#ifndef UNICODE_ONLY
WINADVAPI BOOL WINAPI ChangeServiceConfigA( SC_HANDLE hService, DWORD dwServiceType, DWORD dwStartType, DWORD dwErrorControl, LPCSTR lpBinaryPathName, LPCSTR lpLoadOrderGroup, LPDWORD lpdwTagId, LPCSTR lpDependencies, LPCSTR lpServiceStartName, LPCSTR lpPassword, LPCSTR lpDisplayName ); #endif //!UNICODE_ONLY
#ifndef ANSI_ONLY
WINADVAPI BOOL WINAPI ChangeServiceConfigW( SC_HANDLE hService, DWORD dwServiceType, DWORD dwStartType, DWORD dwErrorControl, LPCWSTR lpBinaryPathName, LPCWSTR lpLoadOrderGroup, LPDWORD lpdwTagId, LPCWSTR lpDependencies, LPCWSTR lpServiceStartName, LPCWSTR lpPassword, LPCWSTR lpDisplayName ); #endif //!ANSI_ONLY
#ifdef UNICODE
#define ChangeServiceConfig ChangeServiceConfigW
#else
#define ChangeServiceConfig ChangeServiceConfigA
#endif // !UNICODE
WINADVAPI BOOL WINAPI CloseServiceHandle( SC_HANDLE hSCObject );
WINADVAPI BOOL WINAPI ControlService( SC_HANDLE hService, DWORD dwControl, LPSERVICE_STATUS lpServiceStatus );
#ifndef UNICODE_ONLY
WINADVAPI SC_HANDLE WINAPI CreateServiceA( SC_HANDLE hSCManager, LPCSTR lpServiceName, LPCSTR lpDisplayName, DWORD dwDesiredAccess, DWORD dwServiceType, DWORD dwStartType, DWORD dwErrorControl, LPCSTR lpBinaryPathName, LPCSTR lpLoadOrderGroup, LPDWORD lpdwTagId, LPCSTR lpDependencies, LPCSTR lpServiceStartName, LPCSTR lpPassword ); #endif //!UNICODE_ONLY
#ifndef ANSI_ONLY
WINADVAPI SC_HANDLE WINAPI CreateServiceW( SC_HANDLE hSCManager, LPCWSTR lpServiceName, LPCWSTR lpDisplayName, DWORD dwDesiredAccess, DWORD dwServiceType, DWORD dwStartType, DWORD dwErrorControl, LPCWSTR lpBinaryPathName, LPCWSTR lpLoadOrderGroup, LPDWORD lpdwTagId, LPCWSTR lpDependencies, LPCWSTR lpServiceStartName, LPCWSTR lpPassword ); #endif //!ANSI_ONLY
#ifdef UNICODE
#define CreateService CreateServiceW
#else
#define CreateService CreateServiceA
#endif // !UNICODE
WINADVAPI BOOL WINAPI DeleteService( SC_HANDLE hService );
#ifndef UNICODE_ONLY
WINADVAPI BOOL WINAPI EnumDependentServicesA( SC_HANDLE hService, DWORD dwServiceState, LPENUM_SERVICE_STATUSA lpServices, DWORD cbBufSize, LPDWORD pcbBytesNeeded, LPDWORD lpServicesReturned ); #endif //!UNICODE_ONLY
#ifndef ANSI_ONLY
WINADVAPI BOOL WINAPI EnumDependentServicesW( SC_HANDLE hService, DWORD dwServiceState, LPENUM_SERVICE_STATUSW lpServices, DWORD cbBufSize, LPDWORD pcbBytesNeeded, LPDWORD lpServicesReturned ); #endif //!ANSI_ONLY
#ifdef UNICODE
#define EnumDependentServices EnumDependentServicesW
#else
#define EnumDependentServices EnumDependentServicesA
#endif // !UNICODE
#ifndef UNICODE_ONLY
WINADVAPI BOOL WINAPI EnumServicesStatusA( SC_HANDLE hSCManager, DWORD dwServiceType, DWORD dwServiceState, LPENUM_SERVICE_STATUSA lpServices, DWORD cbBufSize, LPDWORD pcbBytesNeeded, LPDWORD lpServicesReturned, LPDWORD lpResumeHandle ); #endif //!UNICODE_ONLY
#ifndef ANSI_ONLY
WINADVAPI BOOL WINAPI EnumServicesStatusW( SC_HANDLE hSCManager, DWORD dwServiceType, DWORD dwServiceState, LPENUM_SERVICE_STATUSW lpServices, DWORD cbBufSize, LPDWORD pcbBytesNeeded, LPDWORD lpServicesReturned, LPDWORD lpResumeHandle ); #endif //!ANSI_ONLY
#ifdef UNICODE
#define EnumServicesStatus EnumServicesStatusW
#else
#define EnumServicesStatus EnumServicesStatusA
#endif // !UNICODE
#ifndef UNICODE_ONLY
WINADVAPI BOOL WINAPI GetServiceKeyNameA( SC_HANDLE hSCManager, LPCSTR lpDisplayName, LPSTR lpServiceName, LPDWORD lpcchBuffer ); #endif //!UNICODE_ONLY
#ifndef ANSI_ONLY
WINADVAPI BOOL WINAPI GetServiceKeyNameW( SC_HANDLE hSCManager, LPCWSTR lpDisplayName, LPWSTR lpServiceName, LPDWORD lpcchBuffer ); #endif //!ANSI_ONLY
#ifdef UNICODE
#define GetServiceKeyName GetServiceKeyNameW
#else
#define GetServiceKeyName GetServiceKeyNameA
#endif // !UNICODE
#ifndef UNICODE_ONLY
WINADVAPI BOOL WINAPI GetServiceDisplayNameA( SC_HANDLE hSCManager, LPCSTR lpServiceName, LPSTR lpDisplayName, LPDWORD lpcchBuffer ); #endif //!UNICODE_ONLY
#ifndef ANSI_ONLY
WINADVAPI BOOL WINAPI GetServiceDisplayNameW( SC_HANDLE hSCManager, LPCWSTR lpServiceName, LPWSTR lpDisplayName, LPDWORD lpcchBuffer ); #endif //!ANSI_ONLY
#ifdef UNICODE
#define GetServiceDisplayName GetServiceDisplayNameW
#else
#define GetServiceDisplayName GetServiceDisplayNameA
#endif // !UNICODE
WINADVAPI SC_LOCK WINAPI LockServiceDatabase( SC_HANDLE hSCManager );
WINADVAPI BOOL WINAPI NotifyBootConfigStatus( BOOL BootAcceptable );
#ifndef UNICODE_ONLY
WINADVAPI SC_HANDLE WINAPI OpenSCManagerA( LPCSTR lpMachineName, LPCSTR lpDatabaseName, DWORD dwDesiredAccess ); #endif //!UNICODE_ONLY
#ifndef ANSI_ONLY
WINADVAPI SC_HANDLE WINAPI OpenSCManagerW( LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess ); #endif //!ANSI_ONLY
#ifdef UNICODE
#define OpenSCManager OpenSCManagerW
#else
#define OpenSCManager OpenSCManagerA
#endif // !UNICODE
#ifndef UNICODE_ONLY
WINADVAPI SC_HANDLE WINAPI OpenServiceA( SC_HANDLE hSCManager, LPCSTR lpServiceName, DWORD dwDesiredAccess ); #endif //!UNICODE_ONLY
#ifndef ANSI_ONLY
WINADVAPI SC_HANDLE WINAPI OpenServiceW( SC_HANDLE hSCManager, LPCWSTR lpServiceName, DWORD dwDesiredAccess ); #endif //!ANSI_ONLY
#ifdef UNICODE
#define OpenService OpenServiceW
#else
#define OpenService OpenServiceA
#endif // !UNICODE
#ifndef UNICODE_ONLY
WINADVAPI BOOL WINAPI QueryServiceConfigA( SC_HANDLE hService, LPQUERY_SERVICE_CONFIGA lpServiceConfig, DWORD cbBufSize, LPDWORD pcbBytesNeeded ); #endif //!UNICODE_ONLY
#ifndef ANSI_ONLY
WINADVAPI BOOL WINAPI QueryServiceConfigW( SC_HANDLE hService, LPQUERY_SERVICE_CONFIGW lpServiceConfig, DWORD cbBufSize, LPDWORD pcbBytesNeeded ); #endif //!ANSI_ONLY
#ifdef UNICODE
#define QueryServiceConfig QueryServiceConfigW
#else
#define QueryServiceConfig QueryServiceConfigA
#endif // !UNICODE
#ifndef UNICODE_ONLY
WINADVAPI BOOL WINAPI QueryServiceLockStatusA( SC_HANDLE hSCManager, LPQUERY_SERVICE_LOCK_STATUSA lpLockStatus, DWORD cbBufSize, LPDWORD pcbBytesNeeded ); #endif //!UNICODE_ONLY
#ifndef ANSI_ONLY
WINADVAPI BOOL WINAPI QueryServiceLockStatusW( SC_HANDLE hSCManager, LPQUERY_SERVICE_LOCK_STATUSW lpLockStatus, DWORD cbBufSize, LPDWORD pcbBytesNeeded ); #endif //!ANSI_ONLY
#ifdef UNICODE
#define QueryServiceLockStatus QueryServiceLockStatusW
#else
#define QueryServiceLockStatus QueryServiceLockStatusA
#endif // !UNICODE
WINADVAPI BOOL WINAPI QueryServiceObjectSecurity( SC_HANDLE hService, SECURITY_INFORMATION dwSecurityInformation, PSECURITY_DESCRIPTOR lpSecurityDescriptor, DWORD cbBufSize, LPDWORD pcbBytesNeeded );
WINADVAPI BOOL WINAPI QueryServiceStatus( SC_HANDLE hService, LPSERVICE_STATUS lpServiceStatus );
#ifndef UNICODE_ONLY
WINADVAPI SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerA( LPCSTR lpServiceName, LPHANDLER_FUNCTION lpHandlerProc ); #endif //!UNICODE_ONLY
#ifndef ANSI_ONLY
WINADVAPI SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerW( LPCWSTR lpServiceName, LPHANDLER_FUNCTION lpHandlerProc ); #endif //!ANSI_ONLY
#ifdef UNICODE
#define RegisterServiceCtrlHandler RegisterServiceCtrlHandlerW
#else
#define RegisterServiceCtrlHandler RegisterServiceCtrlHandlerA
#endif // !UNICODE
WINADVAPI BOOL WINAPI SetServiceObjectSecurity( SC_HANDLE hService, SECURITY_INFORMATION dwSecurityInformation, PSECURITY_DESCRIPTOR lpSecurityDescriptor );
WINADVAPI BOOL WINAPI SetServiceStatus( SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus );
#ifndef UNICODE_ONLY
WINADVAPI BOOL WINAPI StartServiceCtrlDispatcherA( LPSERVICE_TABLE_ENTRYA lpServiceStartTable ); #endif //!UNICODE_ONLY
#ifndef ANSI_ONLY
WINADVAPI BOOL WINAPI StartServiceCtrlDispatcherW( LPSERVICE_TABLE_ENTRYW lpServiceStartTable ); #endif //!ANSI_ONLY
#ifdef UNICODE
#define StartServiceCtrlDispatcher StartServiceCtrlDispatcherW
#else
#define StartServiceCtrlDispatcher StartServiceCtrlDispatcherA
#endif // !UNICODE
#ifndef UNICODE_ONLY
WINADVAPI BOOL WINAPI StartServiceA( SC_HANDLE hService, DWORD dwNumServiceArgs, LPCSTR *lpServiceArgVectors ); #endif //!UNICODE_ONLY
#ifndef ANSI_ONLY
WINADVAPI BOOL WINAPI StartServiceW( SC_HANDLE hService, DWORD dwNumServiceArgs, LPCWSTR *lpServiceArgVectors ); #endif //!ANSI_ONLY
#ifdef UNICODE
#define StartService StartServiceW
#else
#define StartService StartServiceA
#endif // !UNICODE
WINADVAPI BOOL WINAPI UnlockServiceDatabase( SC_LOCK ScLock );
#ifdef __cplusplus
} #endif
#endif // _WINSVC_
|