|
Boost Users : |
From: Olenhouse, Jason (jason.olenhouse_at_[hidden])
Date: 2005-03-10 12:16:38
I'm trying to pass a member function pointer around to the Windows Service Control Manager through
Windpws API functions, but I think I'm having troubles with the __stdcall convention.
I'm using MSVC 7.1.3088. For brevity I've left out information, but I think this is enough to go on:
__ExampleClass.h__
class ExampleClass
{
protected:
void Setup( void );
void __stdcall ServiceMain( DWORD dwArgc, LPSTR *lpszArgv );
LPSERVICE_MAIN_FUNCTION m_fServiceMain;
};
__ExampleClass.cpp__
void ExampleClass::Setup( void )
{
boost::function<void ( DWORD, LPSTR * )> f2 = boost::bind( boost::mem_fn( &ExampleClass::ServiceMain
), this, _1, _2 );
m_fServiceMain = f2.target<void ( DWORD, LPSTR * )>( );
SERVICE_TABLE_ENTRY dispatchTable[ ] =
{
{ const_cast<char *>( g_sAPP_NAME.c_str( ) ), m_fServiceMain },
{ 0, 0 }
};
StartServiceCtrlDispatcher( dispatchTable );
}
void __stdcall ExampleClass::ServiceMain( DWORD dwArgc, LPSTR *lpszArgv )
{
}
The error I receive concerns the line
m_fServiceMain = f2.target<void ( DWORD, LPSTR * )>( );
error C2440: '=' : cannot convert from 'void (__cdecl *)(DWORD,LPSTR * )' to
'LPSERVICE_MAIN_FUNCTIONA'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
LPSERVICE_MAIN_FUNCTIONA is defined in "winsvc.h" and is:
typedef VOID (WINAPI *LPSERVICE_MAIN_FUNCTIONA)(
DWORD dwNumServicesArgs,
LPSTR *lpServiceArgVectors
);
Any help or insight would be much appreciated.
-Jason
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net