Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Synopsis
- type HandlerFunction = HANDLE -> ServiceControl -> IO Bool
- type ServiceMainFunction = String -> [String] -> HANDLE -> IO ()
- data ServiceAccept
- data ServiceControl
- data ServiceState
- data ServiceStatus = ServiceStatus {}
- data ServiceType
- queryServiceStatus :: HANDLE -> IO ServiceStatus
- setServiceStatus :: HANDLE -> ServiceStatus -> IO ()
- startServiceCtrlDispatcher :: String -> DWORD -> HandlerFunction -> ServiceMainFunction -> IO ()
Documentation
type HandlerFunction = HANDLE -> ServiceControl -> IO Bool Source #
A handler function is registered with the service dispatcher thread
from a ServiceMainFunction
. The first argument is a HANDLE
returned
from calling registerServiceCtrlHandler
. The second argument represents
the command this service has been directed to perform.
type ServiceMainFunction = String -> [String] -> HANDLE -> IO () Source #
The service dispatcher thread will call each function of this type that you provide. The first argument will be the name of the service. Any additional command-line parameters will appear in the second argument.
Each of these functions should call registerServiceCtrlHandler
to
register a function to handle incoming commands. It should then set
the service's status to StartPending
, and specify that no controls
will be accepted. At this point the function may perform any other
initialization steps before setting the service's status to
Running
. All of this should take no more than 100ms.
data ServiceAccept Source #
The control codes the service accepts and processes in its handler
function (See HandlerFunction
). By default, all services accept the
Interrogate
value. To accept the DEVICEEVENT
value, the service must
register to receive device events by using the
registerDeviceNotification
function.
AcceptNetBindChange | The service is a network component that can accept changes in its
binding without being stopped and restarted. This control code allows
the service to receive |
AcceptParamChange | The service can reread its startup parameters without being stopped
and restarted. This control code allows the service to receive
|
AcceptPauseContinue | The service can be paused and continued. This control code allows the
service to receive |
AcceptPreshutdown | MSDN documentation says that this function is not supported on Windows Server 2003 or Windows XP/2000. The support status on other versions is unknown to me. The service can perform preshutdown tasks. This control code enables
the service to receive |
AcceptShutdown | The service is notified when system shutdown occurs. This control
code allows the service to receive |
AcceptStop | The service can be stopped. This control code allows the service to
receive |
Instances
Show ServiceAccept Source # | |
Defined in System.Win32.Services.Accept showsPrec :: Int -> ServiceAccept -> ShowS # show :: ServiceAccept -> String # showList :: [ServiceAccept] -> ShowS # |
data ServiceControl Source #
A ServiceControl is used in Handler functions. All control codes are
defined here, but some can only be used with a HandlerEx
callback.
Use convertSuccess
to translate from a ServiceControl
to a DWORD
.
Use convertAttempt
to translate from a DWORD
to a ServiceControl
.
Continue | |
Interrogate | |
NetBindAdd | |
NetBindDisable | |
NetBindEnable | |
NetBindRemove | |
ParamChange | |
Pause | |
PreShutdown | |
Shutdown | |
Stop |
Instances
Show ServiceControl Source # | |
Defined in System.Win32.Services.Control showsPrec :: Int -> ServiceControl -> ShowS # show :: ServiceControl -> String # showList :: [ServiceControl] -> ShowS # |
data ServiceState Source #
The current state of a service.
Instances
Eq ServiceState Source # | |
Defined in System.Win32.Services.State (==) :: ServiceState -> ServiceState -> Bool # (/=) :: ServiceState -> ServiceState -> Bool # | |
Show ServiceState Source # | |
Defined in System.Win32.Services.State showsPrec :: Int -> ServiceState -> ShowS # show :: ServiceState -> String # showList :: [ServiceState] -> ShowS # | |
Storable ServiceState Source # | State is stored as a DWORD value in memory. If an undocument value is
encountered during a |
Defined in System.Win32.Services.State sizeOf :: ServiceState -> Int # alignment :: ServiceState -> Int # peekElemOff :: Ptr ServiceState -> Int -> IO ServiceState # pokeElemOff :: Ptr ServiceState -> Int -> ServiceState -> IO () # peekByteOff :: Ptr b -> Int -> IO ServiceState # pokeByteOff :: Ptr b -> Int -> ServiceState -> IO () # peek :: Ptr ServiceState -> IO ServiceState # poke :: Ptr ServiceState -> ServiceState -> IO () # |
data ServiceStatus Source #
Contains status information for a service.
ServiceStatus | |
|
Instances
Show ServiceStatus Source # | |
Defined in System.Win32.Services.Status showsPrec :: Int -> ServiceStatus -> ShowS # show :: ServiceStatus -> String # showList :: [ServiceStatus] -> ShowS # | |
Storable ServiceStatus Source # | |
Defined in System.Win32.Services.Status sizeOf :: ServiceStatus -> Int # alignment :: ServiceStatus -> Int # peekElemOff :: Ptr ServiceStatus -> Int -> IO ServiceStatus # pokeElemOff :: Ptr ServiceStatus -> Int -> ServiceStatus -> IO () # peekByteOff :: Ptr b -> Int -> IO ServiceStatus # pokeByteOff :: Ptr b -> Int -> ServiceStatus -> IO () # peek :: Ptr ServiceStatus -> IO ServiceStatus # poke :: Ptr ServiceStatus -> ServiceStatus -> IO () # |
data ServiceType Source #
Win32 defines many types of services, but this binding only supports Win32OwnProcess.
FileSystemDriver | The service is a file system driver. |
KernelDriver | The service is a device driver. |
Win32OwnProcess | The service runs in its own process. |
Win32ShareProcess | The service shares a process with other services. |
ServiceInteractiveProcess | Do no write your own services of this type. Windows Vista and above prevent service processes from directly interacting with users. A |
Instances
Show ServiceType Source # | |
Defined in System.Win32.Services.Type showsPrec :: Int -> ServiceType -> ShowS # show :: ServiceType -> String # showList :: [ServiceType] -> ShowS # | |
Storable ServiceType Source # | |
Defined in System.Win32.Services.Type sizeOf :: ServiceType -> Int # alignment :: ServiceType -> Int # peekElemOff :: Ptr ServiceType -> Int -> IO ServiceType # pokeElemOff :: Ptr ServiceType -> Int -> ServiceType -> IO () # peekByteOff :: Ptr b -> Int -> IO ServiceType # pokeByteOff :: Ptr b -> Int -> ServiceType -> IO () # peek :: Ptr ServiceType -> IO ServiceType # poke :: Ptr ServiceType -> ServiceType -> IO () # |
:: HANDLE | MSDN documentation: A handle to the service. This handle is returned by the OpenService or the CreateService function, and it must have the SERVICE_QUERY_STATUS access right. For more information, see Service Security and Access Rights. |
-> IO ServiceStatus | This function will throw an
|
Retrieves the current status of the specified service.
:: HANDLE | MSDN documentation: A handle to the status information structure for the current service. This handle is returned by the RegisterServiceCtrlHandlerEx function. |
-> ServiceStatus | MSDN documentation: A pointer to the SERVICE_STATUS structure the contains the latest status information for the calling service. |
-> IO () | This function will throw an
|
Updates the service control manager's status information for the calling service.
startServiceCtrlDispatcher Source #
:: String | The name of the service. According to MSDN documentation this
argument is unused in MSDN description: The name of the service run by the calling thread. This is the service name that the service control program specified in the CreateService function when creating the service. |
-> DWORD |
|
-> HandlerFunction | |
-> ServiceMainFunction | This is a callback function that will be called by the operating system whenever the service is started. It should perform service initialization including the registration of a handler function. MSDN documentation gives conflicting advice as to whether this function should return before the service has entered the stopped state. In the official example the service main function blocks until the service is ready to stop. |
-> IO () | This function will throw an
|
Register a callback function to initialize the service, which will be called by the operating system immediately. startServiceCtrlDispatcher will block until the provided callback function returns.
MSDN documentation: Connects the main thread of a service process to the service control manager, which causes the thread to be the service control dispatcher thread for the calling process.