Win32-services: Windows service applications
This package provides a partial binding to the Win32 System Services API. It's now possible to write Windows service applications using Haskell.
The binding is partial. Here are a few ways in which it differs from the official API:
Only services running within their own process are supported. These are processes of the
WIN32_OWN_PROCESS
type.In cases where multiple versions of the same function exist (for compatibility), this binding only offers one of them.
None of the extended control codes are supported. Handlers you write will automatically report this to the operating system when such controls are received.
Only facilities for writing services are supported; not controlling them.
Effort has been made to simplify using the API without hiding what is
happening behind the scenes. Users are encouraged to read Microsoft's
documentation under 'Dev Center - Desktop > Docs > Desktop app development
documentation > System Services > Services'. The official example has been
ported to Haskell. This can be found in the examples
directory of the
source tree.
Simple Example and Usage
module Main where import Control.Concurrent.MVar import System.Win32.SystemServices.Services main = startServiceCtrlDispatcher "Test" $ name _ -> do mStop <- newEmptyMVar hStatus <- registerServiceCtrlHandlerEx name $ handler mStop setServiceStatus hStatus running takeMVar mStop setServiceStatus hStatus stopped handler mStop hStatus STOP = do setServiceStatus hStatus stopPending putMVar mStop () return True handler _ _ INTERROGATE = return True handler _ _ _ = return False stopped = SERVICE_STATUS WIN32_OWN_PROCESS STOPPED [] nO_ERROR 0 0 0 stopPending = stopped { currentState = STOP_PENDING , waitHint = 3000 } running = stopped { currentState = RUNNING , controlsAccepted = [ACCEPT_STOP] }
C:programmingtest>ghc --make -threaded Main.hs [1 of 1] Compiling Main ( Main.hs, Main.o ) Linking Main.exe ... <linker warnings omitted> C:\programming\test>copy Main.exe c:\svc\Test.exe 1 file(s) copied.
Execute the following from an elevated command prompt to register the service:
C:\svc>sc create Test binPath= c:\svc\Test.exe [SC] CreateService SUCCESS
The service can now be started and stopped from the services console.
Downloads
- Win32-services-0.1.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
Versions [RSS] | 0.1, 0.2, 0.2.1, 0.2.2, 0.2.2.1, 0.2.3, 0.2.3.1, 0.2.4, 0.2.5, 0.2.5.1, 0.3, 0.4, 0.4.0.1 (info) |
---|---|
Dependencies | base (>=4.5 && <4.6), errors, Win32 [details] |
Tested with | ghc ==7.4.2 |
License | BSD-3-Clause |
Copyright | Copyright (C) 2011-2013 Michael Steele |
Author | Michael Steele |
Maintainer | Michael Steele <mikesteele81@gmail.com> |
Category | System |
Home page | http://github.com/mikesteele81/win32-services |
Bug tracker | http://github.com/mikesteele81/win32-services/issues |
Source repo | head: git clone git://github.com/mikesteele81/win32-services.git |
Uploaded | by MichaelSteele at 2013-03-15T00:37:48Z |
Distributions | NixOS:0.4.0.1 |
Reverse Dependencies | 2 direct, 0 indirect [details] |
Downloads | 10464 total (14 in the last 30 days) |
Rating | (no votes yet) [estimated by Bayesian average] |
Your Rating | |
Status | Docs not available [build log] All reported builds failed as of 2016-12-21 [all 7 reports] |