INTRODUCTION: ------------- Ever wanted to have CircleMUD start up and the syslog command prompt box thing not stick out on your desktop? Or maybe you have a computer that multiple people use and they all have a different desktop set to just how they like it so they log off Windows, only to close your MUD window with it? Doesn't that just annoy the crap out of you? Well, a quick and dirty to fix those problems is to run it as a system service. Don't know the Windows API? Don't know how to make or delete a system service? I'll give you the entire howto, and some code to boot. DISCLAIMER: ----------- I am by far not a professional Windows programmer. I only know enough to get Windows to do what I want, but I can almost promise that my code is not the most optimized that it can be. I've learned so much about programming from the CircleMUD community, that it's only fair that I chip in some of my Windows API knowledge and give back. This code was compiled with Microsoft Visual C++ 6.0 on a Windows XP Professional platform. It was tested tried and true on Windows Server 2003, Windows 2000 Server, Windows 2000 Professional, Windows XP Home Edition, Windows XP Professional and even Windows NT 4. As far as I can tell, it works just fine, of course I replaced the actual paths to my executable files with generic ones so people would get the idea a lot quicker. Not saying that people are stupid, but every little bit helps, especially the newbie coders. NT/2000/XP SERVICES CRASH COURSE: --------------------------------- Services run at system startup and generally before anyone logs in. Many services that start up before anyone logs in can be web services such as HTTP servers, MX (Mail eXchanger) servers and so on. Having CircleMUD start up as a system service would not only let your players connect when nobody is actually logged into the computer (by entering a user name and password at the computer itself to log into Windows), but should the power flash or the computer spontaneously reboots (I've had this happen numerous times - real big pain in the ass), when it comes back online, the MUD will be ready to rock. Services have to be added and removed within the code of your program (although there are commercial products that do this task for you) and is actually quite simple. The downside to having it run as a system service is if you love your onscreen syslog so much. I used to, but this just seems more practical, especially since you can set the default logfile in config.c and have a text file with your syslog in it anyway. Basically, you just have to create the service with ::CreateService() and remove it with ::DeleteService(). Amazingly simple, isn't it? Of course there's a bit more to it than just that, such as you have to have the program interpret the different messages the services applet passes to it, all of which is described in the source code by comment blocks. PROGRAM OVERVIEW: ----------------- The little program I whipped up is basically an autorun script that lets you install and remove the system service for the program. By default, the program will just run CircleMUD as an autorun script, responding to .killscript, .fastboot and pause files that CircleMUD created using touch(). This program must be placed within the same folder as your CircleMUD executable (circle.exe), or wherever your .killscript, .fastboot and pause files are placed. Of course you can alter this stuff in the code so that you can have the "autorun program" on your desktop if you really wanted to. I included as much source commenting as I could, but a lot of it is really self-explanatory. You'd be amazed at how generic the Windows API naming convention is... except when you deal with either the registry or using the Direct3D shaders (we'll save that for another time, heh). CREDITS-N-CONTACT: ------------------ So, yeah, I'm Craig and I wrote this little thinger because I am actually working on a MUD and my operating system is Windows 2000.. I don't have anything to show for it yet except for this little thing I just put together. Any questions about this lil program, feel free to contact me at cmackles@msn.com Have fun! --Craig Mackles (cmackles@msn.com)