Integrate vibe.d into Windows Service

Andre Pany andre at s-e-a-p.de
Wed Nov 21 09:59:19 UTC 2018


Hi,

I translated the CPP example of a windows service to D.
https://docs.microsoft.com/en-us/windows/desktop/Services/svc-cpp

I wonder how can I integrate a vibe.d http server here:

__gshared HANDLE ghSvcStopEvent = NULL;

VOID SvcInit(DWORD dwArgc, LPTSTR* lpszArgv)
{
     ghSvcStopEvent = CreateEvent(NULL, // default security 
attributes
             TRUE, // manual reset event
             FALSE, // not signaled
             NULL); // no name

     if (ghSvcStopEvent == NULL)
     {
         ReportSvcStatus(SERVICE_STOPPED, NO_ERROR, 0);
         return;
     }

     ReportSvcStatus(SERVICE_RUNNING, NO_ERROR, 0);

     // TO_DO: Perform work until service stops.
	
     while (1)
     {
         WaitForSingleObject(ghSvcStopEvent, INFINITE);
         ReportSvcStatus(SERVICE_STOPPED, NO_ERROR, 0);
         return;
     }
}

WaitForSingleObject will wait forever until ghSvcStopEvent will 
be filled
(by extern (Windows) VOID SvcCtrlHandler(DWORD dwCtrl) nothrow).

Do you have any proposal how to integrate vibe.d here?

Kind regards
André


More information about the Digitalmars-d-learn mailing list