CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Threaded View

  1. #1
    Join Date
    Jul 2007
    Posts
    10

    Win32 Service doesn't work arghhh

    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
    Last edited by cppnewbie81; July 4th, 2007 at 01:18 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured