Пример #1
0
VOID WINAPI SvcMain( DWORD dwArgc, LPTSTR *lpszArgv )
{
    // Register the handler function for the service

    gSvcStatusHandle = RegisterServiceCtrlHandler(
                           SVCNAME,
                           SvcCtrlHandler);

    if( !gSvcStatusHandle )
    {
        return;
    }

    // These SERVICE_STATUS members remain as set here

    gSvcStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
    gSvcStatus.dwServiceSpecificExitCode = 0;

    // Report initial status to the SCM

    ReportSvcStatus( SERVICE_START_PENDING, NO_ERROR, 3000 );

    // Perform service-specific initialization and work.

    SvcInit( dwArgc, lpszArgv );
}
Пример #2
0
void ServiceMain(int argc, wchar_t *argv[])
{
	gSvcStatusHandle = RegisterServiceCtrlHandler(szServiceName, SvcCtrlHandler);

	if(!gSvcStatusHandle) {
		SvcReportEvent(L"RegisterServiceCtrlHandler");
		return; 
    }

	gSvcStatus.dwServiceType = SERVICE_WIN32; 
	gSvcStatus.dwServiceSpecificExitCode = 0;

	ReportSvcStatus(SERVICE_START_PENDING, NO_ERROR, 3000);

	SvcInit(argc, argv);
}
Пример #3
0
void WINAPI SvcMain(DWORD dwArgc, LPTSTR* lpszArgv)
{
	gSvcStatusHandle = RegisterServiceCtrlHandler(SVCNAME, SvcCtrlHandler);

	if (!gSvcStatusHandle)
	{
		SvcReportWinFuncError(TEXT("RegisterServiceCtrlHandler"));
		return;
	}

	gSvcStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
	gSvcStatus.dwServiceSpecificExitCode = 0;

	ReportSvcStatus(SERVICE_START_PENDING, NO_ERROR, 3000);

	SvcInit(dwArgc, lpszArgv);
}
//
// Purpose: 
//   Entry point for the service
//
// Parameters:
//   dwArgc - Number of arguments in the lpszArgv array
//   lpszArgv - Array of strings. The first string is the name of
//     the service and subsequent strings are passed by the process
//     that called the StartService function to start the service.
// 
// Return value:
//   None.
//
VOID WINAPI SvcMain( DWORD dwArgc, LPTSTR *lpszArgv )
{
	// Register the handler function for the service
	char path[MAX_PATH];
	if( !GetModuleFileName(NULL, path, MAX_PATH ) )
	{
		Trace("Cannot get path of executable\n");//, GetLastError());
		return;
	}

	char *cp = strrchr(path, '\\');
	if (cp != NULL)
	{
		*cp = '\0';
		SetCurrentDirectory(path);
	}

	OutputDebugString("SvcMain setName\n");
	//gService->setName(lpszArgv[0]);
	gSvcStatusHandle = RegisterServiceCtrlHandler( 
		gService->name(), 
		SvcCtrlHandler);

	if( !gSvcStatusHandle )
	{ 
		SvcReportEvent("RegisterServiceCtrlHandler"); 
		return; 
	} 

	// These SERVICE_STATUS members remain as set here

	gSvcStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS; 
	gSvcStatus.dwServiceSpecificExitCode = 0;    

	// Report initial status to the SCM

	ReportSvcStatus( SERVICE_START_PENDING, NO_ERROR, 10000 );

	// Perform service-specific initialization and work.
	Sleep(2000);


	SvcInit( dwArgc, lpszArgv );
}
Пример #5
0
/*! Service entry point
 */
void WINAPI MySvcMain(DWORD dwArgc, LPTSTR *lpszArgv)
{
  // Register service handler.
  gSvcStatusHandle = RegisterServiceCtrlHandler(SVCNAME, SvcCtrlHandler);
  if (!gSvcStatusHandle)
  {
    //SvcReportEvent(TEXT("RegisterServiceCtrlHandler"));
    return;
  }

  gSvcStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
  gSvcStatus.dwServiceSpecificExitCode = 0;

  // Notify the SCM that we are starting the service now.
  ReportSvcStatus(SERVICE_START_PENDING, NO_ERROR, 3000);

  // Perform service specific initialization.
  SvcInit(dwArgc, lpszArgv);
}
Пример #6
0
//
// Purpose: 
//   Entry point for the service
//
// Parameters:
//   dwArgc - Number of arguments in the lpszArgv array
//   lpszArgv - Array of strings. The first string is the name of
//     the service and subsequent strings are passed by the process
//     that called the StartService function to start the service.
// 
// Return value:
//   None.
//
VOID WINAPI SvcMain( DWORD dwArgc, LPTSTR *lpszArgv )
{
  // Register the handler function for the service
  gService->setName(lpszArgv[0]);

  char path[MAX_PATH];
  if( !GetModuleFileName(NULL, path, MAX_PATH ) )
  {
    sLogger << dlib::LERROR << "Cannot get path of executable (" << GetLastError() << ")";
    return;
  }

  std::string wd = path;
  size_t found = wd.rfind('\\');
  if (found != std::string::npos)
  {
    wd.erase(found);
    SetCurrentDirectory(wd.c_str());
  }

  gSvcStatusHandle = RegisterServiceCtrlHandler( 
    gService->name().c_str(), 
    SvcCtrlHandler);

  if( !gSvcStatusHandle )
  { 
    SvcReportEvent("RegisterServiceCtrlHandler"); 
    return; 
  } 

  // These SERVICE_STATUS members remain as set here

  gSvcStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS; 
  gSvcStatus.dwServiceSpecificExitCode = 0;    

  // Report initial status to the SCM

  ReportSvcStatus( SERVICE_START_PENDING, NO_ERROR, 3000 );

  // Perform service-specific initialization and work.

  SvcInit( dwArgc, lpszArgv );
}
Пример #7
0
static void WINAPI
ServiceMain(DWORD dwArgc, LPTSTR *lpszArgv)
{
	/* register the handler function for the service */
	statusHandle = RegisterServiceCtrlHandlerEx(SVCNAME, SvcCtrlHandler, NULL);
	if (!statusHandle)
	{
		SvcReportEvent(TEXT("RegisterServiceCtrlHandler"));
		return;
	}

	status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
	status.dwServiceSpecificExitCode = 0;

	/* report initial status to the SCM */
	report_status(SERVICE_START_PENDING, NO_ERROR, 3000);

	/* report service-specific initialization and work */
	SvcInit(dwArgc, lpszArgv);
}