Windows Service in Blitzmax - Working!

BlitzMax Forums/BlitzMax Programming/Windows Service in Blitzmax - Working!

Scaremonger(Posted 2010) [#1]
WIN32 ONLY

I saw on the forums that it couldn't be done, but I didn't agree, so here it is, a working Windows service.

THIS IS CURRENTLY A BETA - I ONLY FINISHED IT TONIGHT

Sample Beep Service (beepservice.bmx)


Get it here: its_win32service110.zip

Or from my Website

I'll add some documentation and notes both here and on my website another day, and once properly tested I'll add it to the code archives.

To Compile use these build options:
* Debug OFF
* GUI OFF
* Multithreaded ON

To Install the service:
* beepservice.mt.exe /i
To Uninstall
* beepservice.mt.exe /u
To start the service
* net start beepservice
To stop the service
* net stop beepservice

DO NOT RUN IN YOUR IDE - COMPILE IT AND USE THE COMMAND LINE


Galaxy613(Posted 2010) [#2]
I never even thought about doing something like this, what could you use it for?

Kudos for proving nay-sayers wrong :D


Brucey(Posted 2010) [#3]
Who said it couldn't be done?

It's just an app... the same as a screensaver.
As long as you make it follow the rules for the service APIs, there shouldn't be a problem creating it in BlitzMax.


xlsior(Posted 2010) [#4]
Very nice!


Scaremonger(Posted 2010) [#5]
@Galaxy613: A back-end server in a multiplayer game is one use.

@Brucey: When I was looking to see if it had been done before, I found a comment or two saying that Blitzmax didn't expose the correct interfaces for it to work. I didn't believe them. It's only a console application, although it did need to wait for multi-threading support.

I've started a projects page for this app which can be found Here (Lots to do though)...

Si...


Winni(Posted 2010) [#6]
Exe2Service, anyone...? Or SrvAny from Microsoft?

But yes, a Windows service basically is a console app that does not provide and require any direct user interaction.


xlsior(Posted 2010) [#7]
Winni: While you can make a service out of pretty much any program with those, having 3rd party dependencies like that is still not nearly as good a solution as being able to do it natively.


Scaremonger(Posted 2010) [#8]
Version 1.10 is available for download from my website.
* Added support for Pause and Continue

Debugging a Windows Service
Windows services cannot be debugged within your IDE so you need some other way of getting debugging information. Luckily help is at hand. You can either write to the Windows Eventlog, or the Windows Debugger. Functions for both are included in the module.

To write to the windows event log simply make a call to logevent().
...
logevent( "Checkpoint X" )
...
To use the Windows Debugger (Download it from HERE) and within your code, make a call to debug().
...
debug( "Checkpoint Y" )
...



Brucey(Posted 2010) [#9]
Windows services cannot be debugged within your IDE so you need some other way of getting debugging information

Interesting. I'm pretty sure you could "remote debug" from it, given the correct functionality - and supporting debugger.


Scaremonger(Posted 2010) [#10]
Probably. Might look at that somewhere down the line.

I added the OutputDebugString() API call so that I could use the sysinternals debugger and the beep() API. It does the job at the moment. :)


Space_guy(Posted 2010) [#11]
Thanks for the module. I thought i might need it someday and today i did :) Works just like it should


bordeaf(Posted 2014) [#12]
After 4 years the link address is not available anymore. Does anyone has this package its_win32service110.zip? This seems to be the only solution to create a windows service application in blitzmax. Thank you.


xlsior(Posted 2014) [#13]
I don't have the 1.10 version unfortunately, but did find the 1.00 on my computer.

Here's a backup of the module: http://www.xlsior.org/temp/itspeedway.mod.zip


Scaremonger(Posted 2014) [#14]
Hi,
It is now available for download from my sourceforge page.

Cheers,
Si...


xlsior(Posted 2014) [#15]
It is now available for download from my sourceforge page.


That appears to be the 1.0 version as well... Is the 1.10 update still around?


Scaremonger(Posted 2014) [#16]
The download still says v1.00, but version 1.10 is available under files.


bordeaf(Posted 2014) [#17]
Thanks for the links