# C++ code to run as a Windows Service ?



## deuce (May 26, 2001)

Hi,

I have some C++ code that I'm developing that I need to run as a windows service. (I think)

First it might make sense to explain this a bit--maybe someone has a better idea on how to implement this.

I need an application that will read data from a specific file ( YYMMDD(-1).txt That is to say, a text file named with the above date format, but with yesterday's date) everyday at noon.

I need it to check the file for certain conditions (the conditions are a result of certain things the operator needs to be doing). If the conditions are not there, I need it to generate a plain text email to a certain email address.

I figure the way to do this is to write a program and run it as a windows service--so it is always running, wakes up at noon, does it's business and sleeps until the next day at noon. If anyone has a better idea, I would love to hear it.

With that said, in terms of getting C++ code to run as a windows service, can someone give me some direction in finding good info to help with this? It's been a few years since the last time I did a lot of programming, but I think I can handle the C++ code to do what I want. I just have no idea how to setup a windows service. I have searched the internet and read some things, but I haven't hit the ground runnning yet.

These two articles were very informatitive:

http://www.developer.com/net/cplus/article.php/10919_3293351_1

http://msdn.microsoft.com/en-us/library/ms810429.aspx

but I don't seem to have the same wizards as they do in my Visual Studio 2008. (didn't notice which complier (VS version) they used for their examples)

Maybe it's just really late and I'm missing it and I should go home...but I can't seem to get the ball rolling. Any help would be appreciated.

Going home and sleeping sounds nice--I think I'll do that in the mean time.

By the way:

I am using:
Visual Studio 2008 Professional on my desktop at home
Visual C++ 2008 Express on my workstation at work

I am using XP Pro (x86) on my workstation
The code will be implemented on a workstation running XP Pro (x86)

Thanks!


----------



## deuce (May 26, 2001)

Also--can this be done in Visual C++ 2008 Express? Is this something that I need to stick to VS Pro for?

Thanks!


----------



## IMM (Feb 1, 2002)

Is there a reason not to use _task scheduler_ for this?


----------



## deuce (May 26, 2001)

IMM said:


> Is there a reason not to use _task scheduler_ for this?


I forgot about that component in the control panel.

I might be able to use it--it would make my code easier to write.

Can I develop my C++ code, compile it as a .exe and set it up with the task scheduler?

Thanks,
Mike


----------

