Na , Kurt < XXXX@XXXXX.COM > escreveu:
Yes, I'm calling the CoInitialize for each thread that I start.
This is my startup routine..
void ServiceMain(DWORD /*dwArgc*/, LPTSTR* /*lpszArgv*/)
WSAStartup(MAKEWORD(1,1), &m_wsData); // Fill in WSA info
ReportStatusToSCM(SERVICE_STOPPED, ::GetLastError(), 0, 1, 0);
//register our control handler
//Pretend that starting up takes some time
ReportStatusToSCM(SERVICE_START_PENDING, NO_ERROR, 0, 1, 0);
ReportStatusToSCM(SERVICE_RUNNING, NO_ERROR, 0, 1, 0);
//Report to the event log that the service has started successfully
AfxBeginThread(ThreadWork, this, THREAD_PRIORITY_BELOW_NORMAL);
//The tight loop which constitutes the service
//As a demo, we just do a message beep
//Pretend that closing down takes some time
ReportStatusToSCM(SERVICE_STOP_PENDING, NO_ERROR, 0, 1, 0);
ReportStatusToSCM(SERVICE_STOPPED, NO_ERROR, 0, 1, 0);
//Report to the event log that the service has stopped successfully
The thread pointed by ThreadWork, is the one that actualy uses the ADO
Connection; as you can also see, there is a cycle with a socket listener,
for some user interface for special tasks.
I hope it is enough...