I create a win32 service according to the instruction as in following URL:
http://www.codeproject.com/system/wi...nt_service.asp
I am able to install and start the service perfectly without any error by following those instruction.
In the example given, the service will just running and do nothing because there's nothing inside while { } statement in ServiceMain(DWORD argc, LPTSTR *argv) function. Therefore, i add some code inside the while statement. After added in the code, I'm able to install the service, but when i try to start the service it said :
"System error 1067 has occurred. The process terminated unexpectedly". What's actually happened anyone ? The following is my code in ServiceMain function:
Code:void WINAPI ServiceMain(DWORD argc, LPTSTR *argv) { DWORD status; DWORD specificError; m_ServiceStatus.dwServiceType = SERVICE_WIN32; m_ServiceStatus.dwCurrentState = SERVICE_START_PENDING; m_ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP; m_ServiceStatus.dwWin32ExitCode = 0; m_ServiceStatus.dwServiceSpecificExitCode = 0; m_ServiceStatus.dwCheckPoint = 0; m_ServiceStatus.dwWaitHint = 0; m_ServiceStatusHandle = RegisterServiceCtrlHandler("ServiceC", ServiceCtrlHandler); if (m_ServiceStatusHandle == (SERVICE_STATUS_HANDLE)0) { return; } m_ServiceStatus.dwCurrentState = SERVICE_RUNNING; m_ServiceStatus.dwCheckPoint = 0; m_ServiceStatus.dwWaitHint = 0; if (!SetServiceStatus (m_ServiceStatusHandle, &m_ServiceStatus)) { } bRunning = true; while (bRunning) { // The problem occur here, if i comment out all the codes within the while loops it works perfectly TestClassr *tc; tc=new TestClass(); tc->Resume(); bRunning = false; delete tc; tc = 0; } return; }
For you all information, TestClass is a class that is generated from PThread.
PThread = one of the Class from Openh323 (www.openh323.org)
Hope somebobody can help me out. Thanks in advance