Help creating a simple service using ATL Service 
Author Message
 Help creating a simple service using ATL Service

Greetings:

Can someone share a basic project/sample code for creating a windows
service using ATL?

I have not found any documentation or samples for this.

Your help is greatly appreciated.

Thanks in advance.

George

(Please remove text, including the dash for valid email)



Wed, 05 Jan 2005 00:57:04 GMT  
 Help creating a simple service using ATL Service
Hi,

Use the Wizard provided by VC++
Select the ATL COM AppWizard
In the second page, you can select the service...
Later you can insert the ATL objects.. the interfaces you want in the
service..

regards
Satheesh Thomas


Quote:
> Greetings:

> Can someone share a basic project/sample code for creating a windows
> service using ATL?

> I have not found any documentation or samples for this.

> Your help is greatly appreciated.

> Thanks in advance.

> George

> (Please remove text, including the dash for valid email)



Wed, 05 Jan 2005 01:38:46 GMT  
 Help creating a simple service using ATL Service
On Fri, 19 Jul 2002 13:38:46 -0400, "Satheesh Thomas"

Yes, thanks for the quick reply. I have gotten this far, but not sure
how to proceed from here. For example, I have an application with
objects that I now want to make a service.

How do I override Run(), OnStop() etc. as needed. Everything I tried
turns up with a compile error or duplicate name definition.

Do you (or anyone else PLEASE Please please) have a simple service
project that shows how to properly use these templates? How to
override the critical methods (run, stop, shutdown etc).

Thanks in advance.

Quote:
>Hi,

>Use the Wizard provided by VC++
>Select the ATL COM AppWizard
>In the second page, you can select the service...
>Later you can insert the ATL objects.. the interfaces you want in the
>service..

>regards
>Satheesh Thomas



>> Greetings:

>> Can someone share a basic project/sample code for creating a windows
>> service using ATL?

>> I have not found any documentation or samples for this.

>> Your help is greatly appreciated.

>> Thanks in advance.

>> George

>> (Please remove text, including the dash for valid email)

Thanks in advance.

George

(Please remove text, including the dash for valid email)



Wed, 05 Jan 2005 01:48:08 GMT  
 Help creating a simple service using ATL Service
You don't need to override anything. Just implement your COM
objects...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================

Quote:

> On Fri, 19 Jul 2002 13:38:46 -0400, "Satheesh Thomas"

> Yes, thanks for the quick reply. I have gotten this far, but not sure
> how to proceed from here. For example, I have an application with
> objects that I now want to make a service.

> How do I override Run(), OnStop() etc. as needed. Everything I tried
> turns up with a compile error or duplicate name definition.

> Do you (or anyone else PLEASE Please please) have a simple service
> project that shows how to properly use these templates? How to
> override the critical methods (run, stop, shutdown etc).

> Thanks in advance.

> >Hi,

> >Use the Wizard provided by VC++
> >Select the ATL COM AppWizard
> >In the second page, you can select the service...
> >Later you can insert the ATL objects.. the interfaces you want in the
> >service..

> >regards
> >Satheesh Thomas



> >> Greetings:

> >> Can someone share a basic project/sample code for creating a windows
> >> service using ATL?

> >> I have not found any documentation or samples for this.

> >> Your help is greatly appreciated.

> >> Thanks in advance.

> >> George

> >> (Please remove text, including the dash for valid email)

> Thanks in advance.

> George

> (Please remove text, including the dash for valid email)



Wed, 05 Jan 2005 02:36:21 GMT  
 Help creating a simple service using ATL Service
On Fri, 19 Jul 2002 11:36:21 -0700, "Alexander Nickolov"

Thanks for the response, but this is where I am having problems; and
why I was trying to find a simple sample project or cpp file that I
could work off of and figure the rest out.

Alos, why would I not need to override the Run() method? Is that not
where I need to add the calls to my objects and do the setup for my
service by over riding OnInit() ?

Quote:
>You don't need to override anything. Just implement your COM
>objects...

Thanks in advance.

George

(Please remove text, including the dash for valid email)



Wed, 05 Jan 2005 02:41:53 GMT  
 Help creating a simple service using ATL Service
Wait a minute! What are we talking about? COM objects are
created via the class objects and these get registered by the
standard ATL code. You don't need to do anything about it.
If you have some quick startup initialization, just do it before
the class objects are registered. If you have lengthy initialization,
that's tricky. You'll have to spin a thread and register your class
objects anyway. Then inside your objects you have to check if
your lengthy initialization has finished and fail gracefully (by
returning E_FAIL for example) if it hasn't. Also, in the stop
handler you'll need to check if your initialization thread has
finished and stop it if it hasn't (signal it and wait for it to exit,
don't forget to provide timely checkpoints to the SCM). This
is all in the code the ATL appwizard generated for you - edit
it as you see fit. (Still, there's nothing to override...)

On the subject of checkpoints, the ATL generated code has
a bug in handling the startup and shutdown checkpoints - it
passes 0 to SetServiceStatus for SERVICE_START_PENDING and
SERVICE_STOP_PENDING which is invalid - these must be
consecutive integers starting with 1 for the first respective
notification.

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================

Quote:

> On Fri, 19 Jul 2002 11:36:21 -0700, "Alexander Nickolov"

> Thanks for the response, but this is where I am having problems; and
> why I was trying to find a simple sample project or cpp file that I
> could work off of and figure the rest out.

> Alos, why would I not need to override the Run() method? Is that not
> where I need to add the calls to my objects and do the setup for my
> service by over riding OnInit() ?

> >You don't need to override anything. Just implement your COM
> >objects...

> Thanks in advance.

> George

> (Please remove text, including the dash for valid email)



Wed, 05 Jan 2005 02:59:01 GMT  
 Help creating a simple service using ATL Service
On Fri, 19 Jul 2002 11:59:01 -0700, "Alexander Nickolov"

Thats great, and informative.

but, here is what is generated from the wizard in the app.cpp file:

//
// The module attribute causes WinMain to be automatically implemented
for you
//
[ module(SERVICE, uuid = "{390AEDF3-01F6-47E3-B1CB-47ED19EC6267}",
                 name = "MMService",
                 helpstring = "MMService 1.0 Type Library",
                 resource_name="IDS_SERVICENAME") ];

Compiles great. Now, I need to start a couple of threads when the
service started to process some files and do some other work for
example.

Where and how do I do this? How will Run() know to create my thread
objects, how will I clean them up, etc.

PS: I am using Visual Studio .NET, I am hoping there is no major
difference between version 6.x in terms of the code that is generated
from the wizard.

Quote:
>Wait a minute! What are we talking about? COM objects are
>created via the class objects and these get registered by the
>standard ATL code. You don't need to do anything about it.
>If you have some quick startup initialization, just do it before
>the class objects are registered. If you have lengthy initialization,
>that's tricky. You'll have to spin a thread and register your class
>objects anyway. Then inside your objects you have to check if
>your lengthy initialization has finished and fail gracefully (by
>returning E_FAIL for example) if it hasn't. Also, in the stop
>handler you'll need to check if your initialization thread has
>finished and stop it if it hasn't (signal it and wait for it to exit,
>don't forget to provide timely checkpoints to the SCM). This
>is all in the code the ATL appwizard generated for you - edit
>it as you see fit. (Still, there's nothing to override...)

>On the subject of checkpoints, the ATL generated code has
>a bug in handling the startup and shutdown checkpoints - it
>passes 0 to SetServiceStatus for SERVICE_START_PENDING and
>SERVICE_STOP_PENDING which is invalid - these must be
>consecutive integers starting with 1 for the first respective
>notification.

Thanks in advance.

George

(Please remove text, including the dash for valid email)



Wed, 05 Jan 2005 03:12:20 GMT  
 Help creating a simple service using ATL Service

Quote:
> Greetings:

> Can someone share a basic project/sample code for creating a windows
> service using ATL?

> I have not found any documentation or samples for this.

> Your help is greatly appreciated.

> Thanks in advance.

> George

> (Please remove text, including the dash for valid email)

This may help get you started:

http://www.codeproject.com/system/cntservice.asp

It uses MFC which I try to avoid so an alternative which I have also used
is:

http://www.codeguru.com/system/nt_service.shtml

Pay close attention to event viewer messages and it will be fine.

--
Adrian Edmonds
Your voice is your key
http://www.voiceprove.com



Thu, 06 Jan 2005 16:17:53 GMT  
 Help creating a simple service using ATL Service
On Sun, 21 Jul 2002 10:17:53 +0200, "Adrian Edmonds"

Thanks, I actually did use this sample. Works great. The project I
need to port uses MFC heavily, so I thought using the ATL version
would help me out a bit. Unfortuantley I am not sure if the wizard is
broken since it only generates a single cpp file with a module
statement.

Quote:


>> Greetings:

>> Can someone share a basic project/sample code for creating a windows
>> service using ATL?

>> I have not found any documentation or samples for this.

>> Your help is greatly appreciated.

>> Thanks in advance.

>> George

>> (Please remove text, including the dash for valid email)

>This may help get you started:

>http://www.codeproject.com/system/cntservice.asp

>It uses MFC which I try to avoid so an alternative which I have also used
>is:

>http://www.codeguru.com/system/nt_service.shtml

>Pay close attention to event viewer messages and it will be fine.

Thanks in advance.

George

(Please remove text, including the dash for valid email)



Fri, 07 Jan 2005 00:23:31 GMT  
 Help creating a simple service using ATL Service
I just want to bring to your attention the fact that MFC is officially
unsupported in services...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================

Quote:

> On Sun, 21 Jul 2002 10:17:53 +0200, "Adrian Edmonds"

> Thanks, I actually did use this sample. Works great. The project I
> need to port uses MFC heavily, so I thought using the ATL version
> would help me out a bit. Unfortuantley I am not sure if the wizard is
> broken since it only generates a single cpp file with a module
> statement.



> >> Greetings:

> >> Can someone share a basic project/sample code for creating a windows
> >> service using ATL?

> >> I have not found any documentation or samples for this.

> >> Your help is greatly appreciated.

> >> Thanks in advance.

> >> George

> >> (Please remove text, including the dash for valid email)

> >This may help get you started:

> >http://www.codeproject.com/system/cntservice.asp

> >It uses MFC which I try to avoid so an alternative which I have also used
> >is:

> >http://www.codeguru.com/system/nt_service.shtml

> >Pay close attention to event viewer messages and it will be fine.

> Thanks in advance.

> George

> (Please remove text, including the dash for valid email)



Sat, 08 Jan 2005 08:39:27 GMT  
 Help creating a simple service using ATL Service
Uh... No idea about VC 7.0. Unfortunately, the service approach
seems to be a major change and I don't have ATL 7.0 to compare...
In VC 6.0 all code was in plain view and one could (relatively)
easily fix the bugs and insert code...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================

Quote:

> On Fri, 19 Jul 2002 11:59:01 -0700, "Alexander Nickolov"

> Thats great, and informative.

> but, here is what is generated from the wizard in the app.cpp file:

> //
> // The module attribute causes WinMain to be automatically implemented
> for you
> //
> [ module(SERVICE, uuid = "{390AEDF3-01F6-47E3-B1CB-47ED19EC6267}",
> name = "MMService",
> helpstring = "MMService 1.0 Type Library",
> resource_name="IDS_SERVICENAME") ];

> Compiles great. Now, I need to start a couple of threads when the
> service started to process some files and do some other work for
> example.

> Where and how do I do this? How will Run() know to create my thread
> objects, how will I clean them up, etc.

> PS: I am using Visual Studio .NET, I am hoping there is no major
> difference between version 6.x in terms of the code that is generated
> from the wizard.

> >Wait a minute! What are we talking about? COM objects are
> >created via the class objects and these get registered by the
> >standard ATL code. You don't need to do anything about it.
> >If you have some quick startup initialization, just do it before
> >the class objects are registered. If you have lengthy initialization,
> >that's tricky. You'll have to spin a thread and register your class
> >objects anyway. Then inside your objects you have to check if
> >your lengthy initialization has finished and fail gracefully (by
> >returning E_FAIL for example) if it hasn't. Also, in the stop
> >handler you'll need to check if your initialization thread has
> >finished and stop it if it hasn't (signal it and wait for it to exit,
> >don't forget to provide timely checkpoints to the SCM). This
> >is all in the code the ATL appwizard generated for you - edit
> >it as you see fit. (Still, there's nothing to override...)

> >On the subject of checkpoints, the ATL generated code has
> >a bug in handling the startup and shutdown checkpoints - it
> >passes 0 to SetServiceStatus for SERVICE_START_PENDING and
> >SERVICE_STOP_PENDING which is invalid - these must be
> >consecutive integers starting with 1 for the first respective
> >notification.

> Thanks in advance.

> George

> (Please remove text, including the dash for valid email)



Sat, 08 Jan 2005 08:38:05 GMT  
 Help creating a simple service using ATL Service
On Mon, 22 Jul 2002 17:39:27 -0700, "Alexander Nickolov"

Thank you.

Quote:
>I just want to bring to your attention the fact that MFC is officially
>unsupported in services...

Thanks in advance.

George

(Please remove text, including the dash for valid email)



Sun, 09 Jan 2005 02:30:09 GMT  
 Help creating a simple service using ATL Service
On Mon, 22 Jul 2002 17:39:27 -0700, "Alexander Nickolov"

Shot off the response too quick. Actually I used CString heavily, but
I'll search for a replacement and work on VS 6.0 for this project.

Perhaps someone at Microsoft can lend a hand and port the services
example in MSDN over to VC 7.0 .... (hint hint hint...............).

Quote:
>I just want to bring to your attention the fact that MFC is officially
>unsupported in services...

Thanks in advance.

George

(Please remove text, including the dash for valid email)



Sun, 09 Jan 2005 02:39:33 GMT  
 Help creating a simple service using ATL Service
WTL has CString.

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================

Quote:

> On Mon, 22 Jul 2002 17:39:27 -0700, "Alexander Nickolov"

> Shot off the response too quick. Actually I used CString heavily, but
> I'll search for a replacement and work on VS 6.0 for this project.

> Perhaps someone at Microsoft can lend a hand and port the services
> example in MSDN over to VC 7.0 .... (hint hint hint...............).

> >I just want to bring to your attention the fact that MFC is officially
> >unsupported in services...

> Thanks in advance.

> George

> (Please remove text, including the dash for valid email)



Mon, 10 Jan 2005 02:07:59 GMT  
 
 [ 14 post ] 

 Relevant Pages 

1. NT Service Using MFC (Samples\sdk\winnt\service) PLEASE HELP

2. problem in building NT service using ATL wizard in release mode..Please help

3. Cannot start service ATL COM Service

4. ATL Service service could not be deleted message???

5. ATL Service only start as service

6. ATL as Service : Service State Handler

7. ATL Service - Sporadically does not report SERVICE STOP in event log

8. Simple Question About ATL Service Wizard?

9. Simple ATL Object in my Windows Service

10. Simple ATL 7.0 Service question

11. creating a very simple service

12. PreMessageLoop Failed when create blank ATL service (VC++7.0)

 

 
Powered by phpBB® Forum Software