Re: Migrating ATL Service to VS2005
class CTestServiceModule : public CAtlServiceModuleT< CTestServiceModule,
IDS_SERVICENAME >
{
public :
CTestServiceModule ()
{
m_status.dwControlsAccepted = SERVICE_ACCEPT_STOP |
SERVICE_ACCEPT_SESSIONCHANGE;
}
void OnShutdown() throw()
{
//shutdown code goes here
}
<sergio.ortiz.giner@gmail.com> wrote in message
news:1152272826.783263.78000@k73g2000cwa.googlegroups.com...
Hi all,
I am trying to migrate an existing ATL service to VS2005.
This module uses HandlerEx to receive SERVICE_CONTROL_SESSIONCHANGE and
analyses lpEventData provided.
After arranging the module to make use of CAtlServiceModuleT, I'm quite
surprised to see that this new base class does not support HandlerEx (
I've confirmed it by looking at atlbase.h...see lines below)
[Extract from atlbase.h - line aprox.3708]
void ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv) throw()
{
lpszArgv;
dwArgc;
// Register the control request handler
m_status.dwCurrentState = SERVICE_START_PENDING;
m_hServiceStatus = RegisterServiceCtrlHandler(m_szServiceName,
_Handler);
....
Is there any official/recommended way of taclking this issue or should
I create my own base class?
Don't create your own base class. Simply override the constructor, as in:
class CTestServiceModule : public CAtlServiceModuleT< CTestServiceModule,
IDS_SERVICENAME >
{
public :
CTestServiceModule ()
{
m_status.dwControlsAccepted = SERVICE_ACCEPT_STOP |
SERVICE_ACCEPT_SESSIONCHANGE;
}
void OnUnknownRequest (DWORD dwOpcode) throw()
{
if (dwOpcode == SERVICE_CONTROL_SESSIONCHANGE)
{
... do this
}
else
{
CAtlServiceModuleT<CTestServiceModule,
IDS_SERVICENAME>::OnUnknownRequest (dwOpcode);
}
}
(note: I haven't debugged, but this should be very close)
HTH
Brian