www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Re: Examples of Windows services in D?

reply DNewbie <run3 myopera.com> writes:
Here is a simple service in D
http://my.opera.com/run3/blog/2012/02/23/windows-services-in-d
It's basically c translated to d.


On Tue, Feb 21, 2012, at 03:08 PM, Graham Fawcett wrote:
 Hi folks,
 
 I've got a Windows service that I'd like to write in D, if possible. I 
 see that Andrej Mitrovic has provided a binding for the relevant parts of 
 the Windows API (thanks!):
 
 https://github.com/AndrejMitrovic/DWinProgramming/blob/master/win32/
 winsvc.d
 
 Has anyone used this (or another binding) to write an actual service? 
 Particularly, I was hoping to find a "base class" that takes care of 
 common tasks (installing, removing, starting, etc.).
 
 Thanks!
 Graham
 

Feb 22 2012
parent Graham Fawcett <fawcett uwindsor.ca> writes:
On Thu, 23 Feb 2012 02:33:04 +0100, DNewbie wrote:

 Here is a simple service in D
 http://my.opera.com/run3/blog/2012/02/23/windows-services-in-d It's
 basically c translated to d.

Hey, thanks for this. I ended up doing the same thing (translating an existing service from C++). But my code is messy, and I shall mine your example for improvements. :) I am *very* glad I could write this thing in D! One thing that bit me: if you want to use an extended Service Control Handler (RegisterServiceCtrlHandlerEx), these functions are absent from advapi32.lib (at least in my recent version of DMD). I had to include a linkage.def file, when linking, to get it working: EXETYPE NT IMPORTS RegisterServiceCtrlHandlerExA 12 = advapi32.RegisterServiceCtrlHandlerExA Cheers, Graham
 
 
 On Tue, Feb 21, 2012, at 03:08 PM, Graham Fawcett wrote:
 Hi folks,
 
 I've got a Windows service that I'd like to write in D, if possible. I
 see that Andrej Mitrovic has provided a binding for the relevant parts
 of the Windows API (thanks!):
 
 https://github.com/AndrejMitrovic/DWinProgramming/blob/master/win32/
 winsvc.d
 
 Has anyone used this (or another binding) to write an actual service?
 Particularly, I was hoping to find a "base class" that takes care of
 common tasks (installing, removing, starting, etc.).
 
 Thanks!
 Graham


Feb 23 2012