Conventional wisdom says developing services for Windows
NT and 2000 is one of those things you can't do with Visual
Basic. This isn't the case: It's quite possible to use VB (or
Delphi or C++) … if you like obscure API calls,
frustrating threading issues, and the odd crash. Writing, and
especially debugging, service code isn't pleasant regardless
of which language you use, because you're dealing with code
quite close to the operating system, with its own set of
strict rules on what you can or can't do.
Desaware NT Service Toolkit 1.0 solves this problem for VB
programmers in an interesting way: It comes with a precompiled
generic C++ wrapper instead of bleeding-edge VB code. This
wrapper, which you can configure to suit your needs using a
wizard-style utility, implements the basic service interface
toward the operating system, and takes care of all associated
threading issues as well. You provide the actual functionality
for the service using an ActiveX DLL written in VB. Your
service can be up and running in minutes if you use the
supplied template code and configure some minimal information.
The ActiveX DLL approach also frees you from worries
associated usually with developing services and leaves you
with a well-defined interface. Your service can do nearly
anything a regular VB program can, such as using and exposing
other ActiveX components. In the latter case, you can even
create these objects on a different thread from your service
object (using a thread pool of user-configurable size) so they
won't interfere with your main code. You can also create
background threads, which you control by using regular Win32
synchronization objects.
Debugging is easy because you're dealing with 100-percent
native VB code. Launch your service in simulator mode, and you
have access to the complete VB debugger with all its usual
conveniences, earning you the instant envy of all C++
programmers around you. One annoyance is the difficulty in
selecting code and menus, or using auto-complete, because the
simulator causes a noticeable flicker in the IDE.
Other caveats with the NT Service Toolkit: You need
advanced Win32 API knowledge to take advantage of its more
advanced features, and you must spend time cutting and pasting
template code and running external wizards, because the amount
of integration with the VB environment is minimal.
Overall, the Desaware NT Service Toolkit not only saves you
lots of time, but offers unmatched stability as well. Check
out the demo on the Desaware Web site first before you
contemplate creating Win32 services without it.
Michiel de Bruijn lives in Rotterdam, Netherlands, and
spends his days as a networking and development specialist
for an international media group. He seems to enjoy living
on the bleeding edge of technology. Michiel always welcomes
questions and comments; reach him at mdb@x42.net.