How to write services with ATL in VisualStudio.NET 
Author Message
 How to write services with ATL in VisualStudio.NET

Hi everybody,

does anybody know to write services with ATL within VisualStudio.NET ?

I can't find any docs telling me, where I have to put my code that should be
executed after the services is started and running..

Do I have override a certain Method in the CAltServiceModuleT-class?

Thanks for help,
Andy



Sat, 29 Jan 2005 22:01:27 GMT  
 How to write services with ATL in VisualStudio.NET
Hi,

    In ATL 7 you have two option when writting service using attribute and
not using attribute, if you didn't select the attribute, you can overide any
member by selecting the class "CServiceTestModule" depend on the name of you
service, than click on the override button in the property windows to
override any member, if you look in the help to the member of
"CAltServiceModuleT", you will find it much more than what is showing in the
property windows, so any extra member you can override it manual like
"OnStop(), OnContinue()...", you will find the member name very like the old
service in ATL 3 with some minor change, and than you can add any COM to the
project as before.

    If you select the attribute project, it exactly the same as the none
attribute project but first you must to declare manually the class
"CServiceTestModule"  between the ';' and the attribut before overload any
member, after declaring the class you will find the overrides button in the
property windows is enable and then continue as without attribute.

   for example if the wizard create the project like:

// The module attribute causes WinMain to be automatically implemented for
you

[ module(SERVICE, uuid = "{35FC66AA-041C-43BB-BC7A-B9DE18EA9582}",

name = "ServiceTest1",

helpstring = "ServiceTest1 1.0 Type Library",

resource_name="IDS_SERVICENAME") ];

Just chang it to:

// The module attribute causes WinMain to be automatically implemented for
you

[ module(SERVICE, uuid = "{35FC66AA-041C-43BB-BC7A-B9DE18EA9582}",

name = "ServiceTest1",

helpstring = "ServiceTest1 1.0 Type Library",

resource_name="IDS_SERVICENAME") ]

class CServiceTest1Module

{

        public:

Quote:
}

;

Regards,
Emad


Quote:
> Hi everybody,

> does anybody know to write services with ATL within VisualStudio.NET ?

> I can't find any docs telling me, where I have to put my code that should
be
> executed after the services is started and running..

> Do I have override a certain Method in the CAltServiceModuleT-class?

> Thanks for help,
> Andy



Mon, 31 Jan 2005 06:15:07 GMT  
 How to write services with ATL in VisualStudio.NET
Hi Emad,

thank you for answering me.

But which member I have to override for excecuting my code during the
service runs?

I tried run but it doesn't work.

HRESULT Run(int nShowCmd = SW_HIDE){

(...some code...)

return CAtlServiceModuleT::Run(nShowCmd);

Quote:
}

The compiler states errors by calling the base member

Regards,
Andy



Quote:
> Hi,

>     In ATL 7 you have two option when writting service using attribute and
> not using attribute, if you didn't select the attribute, you can overide
any
> member by selecting the class "CServiceTestModule" depend on the name of
you
> service, than click on the override button in the property windows to
> override any member, if you look in the help to the member of
> "CAltServiceModuleT", you will find it much more than what is showing in
the
> property windows, so any extra member you can override it manual like
> "OnStop(), OnContinue()...", you will find the member name very like the
old
> service in ATL 3 with some minor change, and than you can add any COM to
the
> project as before.

>     If you select the attribute project, it exactly the same as the none
> attribute project but first you must to declare manually the class
> "CServiceTestModule"  between the ';' and the attribut before overload any
> member, after declaring the class you will find the overrides button in
the
> property windows is enable and then continue as without attribute.

>    for example if the wizard create the project like:

> // The module attribute causes WinMain to be automatically implemented for
> you

> [ module(SERVICE, uuid = "{35FC66AA-041C-43BB-BC7A-B9DE18EA9582}",

> name = "ServiceTest1",

> helpstring = "ServiceTest1 1.0 Type Library",

> resource_name="IDS_SERVICENAME") ];

> Just chang it to:

> // The module attribute causes WinMain to be automatically implemented for
> you

> [ module(SERVICE, uuid = "{35FC66AA-041C-43BB-BC7A-B9DE18EA9582}",

> name = "ServiceTest1",

> helpstring = "ServiceTest1 1.0 Type Library",

> resource_name="IDS_SERVICENAME") ]

> class CServiceTest1Module

> {

>         public:

> }

> ;

> Regards,
> Emad



> > Hi everybody,

> > does anybody know to write services with ATL within VisualStudio.NET ?

> > I can't find any docs telling me, where I have to put my code that
should
> be
> > executed after the services is started and running..

> > Do I have override a certain Method in the CAltServiceModuleT-class?

> > Thanks for help,
> > Andy



Mon, 31 Jan 2005 16:04:41 GMT  
 How to write services with ATL in VisualStudio.NET
Hi,

    I override the "HRESULT PreMessageLoop(int nShowCmd);" from this member
I created a thread (all my normal code in the thread function.) and I
controlled the thread from "OnStop(), OnContinue, OnPause" member, but any
memebr you override you must call at the end the parent member, if you
didn't add any COM component and you tried to register this service as a
service and start it from MMC, the service will stop automatic and will not
continue, to make work fine add a COM component to the service without any
other change or if you wanna use it as a normal service without taking the
advange of COM just when override "HRESULT PreMessageLoop(int nShowCmd);"
always return S_OK like that:

HRESULT CServiceTestModule::PreMessageLoop(int nShowCmd)

{

//-- ur code here which will create another thread or do some
initialization --

CAtlServiceModuleT<CheckLicenseModule,IDS_SERVICENAME>::PreMessageLoop(nShow
Cmd);

return S_OK; //-- always return S_OK --

Quote:
}

why it fail if you didn't do that, because if u didn't add any COM the
"PreMessageLoop" member will fail to register this service as a COM server.
Don't any member you override you must at the end call its member parent or
look what the parent do exactly.

Regards,
Emad


Quote:
> Hi Emad,

> thank you for answering me.

> But which member I have to override for excecuting my code during the
> service runs?

> I tried run but it doesn't work.

> HRESULT Run(int nShowCmd = SW_HIDE){

> (...some code...)

> return CAtlServiceModuleT::Run(nShowCmd);

> }

> The compiler states errors by calling the base member

> Regards,
> Andy



> > Hi,

> >     In ATL 7 you have two option when writting service using attribute
and
> > not using attribute, if you didn't select the attribute, you can overide
> any
> > member by selecting the class "CServiceTestModule" depend on the name of
> you
> > service, than click on the override button in the property windows to
> > override any member, if you look in the help to the member of
> > "CAltServiceModuleT", you will find it much more than what is showing in
> the
> > property windows, so any extra member you can override it manual like
> > "OnStop(), OnContinue()...", you will find the member name very like the
> old
> > service in ATL 3 with some minor change, and than you can add any COM to
> the
> > project as before.

> >     If you select the attribute project, it exactly the same as the none
> > attribute project but first you must to declare manually the class
> > "CServiceTestModule"  between the ';' and the attribut before overload
any
> > member, after declaring the class you will find the overrides button in
> the
> > property windows is enable and then continue as without attribute.

> >    for example if the wizard create the project like:

> > // The module attribute causes WinMain to be automatically implemented
for
> > you

> > [ module(SERVICE, uuid = "{35FC66AA-041C-43BB-BC7A-B9DE18EA9582}",

> > name = "ServiceTest1",

> > helpstring = "ServiceTest1 1.0 Type Library",

> > resource_name="IDS_SERVICENAME") ];

> > Just chang it to:

> > // The module attribute causes WinMain to be automatically implemented
for
> > you

> > [ module(SERVICE, uuid = "{35FC66AA-041C-43BB-BC7A-B9DE18EA9582}",

> > name = "ServiceTest1",

> > helpstring = "ServiceTest1 1.0 Type Library",

> > resource_name="IDS_SERVICENAME") ]

> > class CServiceTest1Module

> > {

> >         public:

> > }

> > ;

> > Regards,
> > Emad



> > > Hi everybody,

> > > does anybody know to write services with ATL within VisualStudio.NET ?

> > > I can't find any docs telling me, where I have to put my code that
> should
> > be
> > > executed after the services is started and running..

> > > Do I have override a certain Method in the CAltServiceModuleT-class?

> > > Thanks for help,
> > > Andy



Tue, 01 Feb 2005 00:29:27 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How to write services with ATL in VisualStudo.NET

2. VisualStudio 6.0 and VisualStudio.NET interop.

3. ATL component written in VC.NET 2002 won't register on non .NET machine

4. ATL component written in VC.NET 2002 won't register on non .NET machine

5. Writing ATL NT Service

6. Writing service on atributed ATL project

7. ATL Service: only one user with write rights

8. info on writing Services using ATL

9. Good book about writing NT System services via ATL

10. writing NT win32 services with atl -help is needed

11. com+ service written in ATL?

12. Where's VisualStudio Service Pack 2?

 

 
Powered by phpBB® Forum Software