#include <windows.h>

#include <stdio.h>

void RegEventSource();

VOID _CRTAPI1 main(void)

{

LPCTSTR lpszBinaryPathName =

TEXT("c:\\ibserver\\bin\\CommServ.exe");

SC_HANDLE schSCManager;

SC_HANDLE schService;

/* Open a handle to the SC Manager database. */

schSCManager = OpenSCManager(

NULL, /* local machine */

NULL, /* ServicesActive database */

SC_MANAGER_ALL_ACCESS); /* full access rights */

if (schSCManager == NULL) {

printf("\nError opening Service Manager.\n");

return;

}

schService = CreateService(

schSCManager, /* SCManager database */

TEXT("CommServ"), /* name of service */

TEXT("JSC \"SvjazInform\" Communication Service"), /* service name to display */

SERVICE_ALL_ACCESS, /* desired access */

SERVICE_WIN32_OWN_PROCESS, /* service type */

SERVICE_DEMAND_START, /* start type */

SERVICE_ERROR_NORMAL, /* error control type */

lpszBinaryPathName, /* service's binary */

NULL, /* no load ordering group */

NULL, /* no tag identifier */

NULL, /* no dependencies */

NULL, /* LocalSystem account */

NULL); /* no password */

if (schService == NULL) {

printf("\nFailed to create service!\n");

}

else

printf("CreateService SUCCESS\n");

CloseServiceHandle(schService);

CloseServiceHandle(schSCManager);

RegEventSource();

}