Exemple #1
0
static BOOL
DoCreate(PCREATE_DATA Data)
{
    SC_HANDLE hSCManager;
    SC_HANDLE hSc;
    BOOL bRet = FALSE;

    /* open handle to the SCM */
    hSCManager = OpenSCManager(NULL,
                               NULL,
                               SC_MANAGER_ALL_ACCESS);
    if (hSCManager)
    {
        hSc = CreateService(hSCManager,
                            Data->ServiceName,
                            Data->DisplayName,
                            SERVICE_ALL_ACCESS,
                            SERVICE_WIN32_OWN_PROCESS,
                            SERVICE_DEMAND_START,
                            SERVICE_ERROR_NORMAL,
                            Data->BinPath,
                            NULL,
                            NULL,
                            NULL,
                            NULL,
                            NULL);

        if (hSc)
        {
            LPTSTR lpSuccess;

            /* Set the service description as CreateService
               does not do this for us */
            SetServiceDescription(Data->ServiceName,
                                  Data->Description);

            /* report success to user */
            if (AllocAndLoadString(&lpSuccess,
                                   hInstance,
                                   IDS_CREATE_SUCCESS))
            {
                DisplayString(lpSuccess);

                HeapFree(ProcessHeap,
                         0,
                         lpSuccess);
            }

            CloseServiceHandle(hSc);
            bRet = TRUE;
        }

        CloseServiceHandle(hSCManager);
    }

    return bRet;
}
Exemple #2
0
bool CW32Service::ISRV_AttachLogic(IServiceLogic* pLogic)
{
  if ( !pLogic )
    return false;

  SetServiceName( pLogic->GetName() );
  SetServiceDescription( pLogic->GetDesc() );
  m_pLogic = pLogic;

  return true;
}