title: How to Debug a Windows Service
body: <p>I have create a windows service using the <a href="http://www.codeproject.com/KB/system/windows_nt_service.aspx" rel="nofollow">Code Project</a> Article. I am able to install the service and delete the service using -i and -d switch.</p>
  
  <p>I am able to see the service in services.msc but when I start the service it does nothing.Below I will proide the service main code:</p>
  
  <pre><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("Service1", 
                                              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, &amp;m_ServiceStatus))
    {
    }
  
    bRunning=true;
    while(bRunning)
    {
  
      Sleep(150000);
      ShellExecute(NULL, "open", "C:\\", NULL, NULL, SW_SHOWNORMAL);
  
    }
    return;
  }
  </code></pre>
  
  <p>But while  I start the service neither it sleeps or starts the explorer. Am I missing anything?</p>