Windows NT ( 2)



         

SRVCTRL - 3


//

case ID_SERVICE_INSTALL:

{

//

schSCManager = OpenSCManager(NULL, NULL,

SC_MANAGER_ALL_ACCESS);

if(!schSCManager)

break;

// MYServiceName

schService = CreateService(

schSCManager,

MYServiceName,

MYServiceName,

SERVICE_ALL_ACCESS,

SERVICE_WIN32_OWN_PROCESS,

SERVICE_DEMAND_START,

SERVICE_ERROR_NORMAL,

"c:\\ntbk2\\src\\service\\small\\debug\\small.exe",

NULL,

NULL,

"",

NULL,

NULL);

//

//

CloseServiceHandle(schSCManager);

break;

}

//

case ID_SERVICE_REMOVE:

{

//

schSCManager = OpenSCManager(NULL, NULL,

SC_MANAGER_ALL_ACCESS);

if(!schSCManager)

break;

// MYServiceName

schService = OpenService(

schSCManager, MYServiceName,

SERVICE_ALL_ACCESS);

if(!schService)

break;

//

ControlService(schService,

SERVICE_CONTROL_STOP, &ss);

//

DeleteService(schService);

//

//

CloseServiceHandle(schSCManager);

break;

}

case ID_SERVICE_START:

{

//

schSCManager = OpenSCManager(NULL, NULL,

SC_MANAGER_ALL_ACCESS);

if(!schSCManager)

break;

// MYServiceName

schService = OpenService(

schSCManager, MYServiceName,