3,245
社区成员
发帖
与我相关
我的任务
分享
SERVICE_STATUS state;
SERVICE_STATUS_HANDLE stateHandle;
void CallBackControlHandler(DWORD request)
{
switch (request)
{
case SERVICE_CONTROL_STOP:
state.dwWin32ExitCode = 0;
state.dwCurrentState = SERVICE_RUNNING;
//state.dwCurrentState = SERVICE_STOPPED;
SetServiceStatus(stateHandle, &state);
break;
default:
break;
}
}
意思就是在停止的时候不让它停止
理论上case SERVICE_CONTROL_STOP的时候直接break掉就可以
dwControlsAccepted
The control codes the service accepts and processes in its handler function (see Handler and HandlerEx). A user interface process can control a service by specifying a control command in the ControlService or ControlServiceEx function. By default, all services accept the SERVICE_CONTROL_INTERROGATE value. To accept the SERVICE_CONTROL_DEVICEEVENT value, the service must register to receive device events by using the RegisterDeviceNotification function.
The following are the control codes.
Control code Meaning
SERVICE_ACCEPT_NETBINDCHANGE
0x00000010 The service is a network component that can accept changes in its binding without being stopped and restarted.
This control code allows the service to receive SERVICE_CONTROL_NETBINDADD, SERVICE_CONTROL_NETBINDREMOVE, SERVICE_CONTROL_NETBINDENABLE, and SERVICE_CONTROL_NETBINDDISABLE notifications.
SERVICE_ACCEPT_PARAMCHANGE
0x00000008 The service can reread its startup parameters without being stopped and restarted.
This control code allows the service to receive SERVICE_CONTROL_PARAMCHANGE notifications.
SERVICE_ACCEPT_PAUSE_CONTINUE
0x00000002 The service can be paused and continued.
This control code allows the service to receive SERVICE_CONTROL_PAUSE and SERVICE_CONTROL_CONTINUE notifications.
SERVICE_ACCEPT_PRESHUTDOWN
0x00000100 The service can perform preshutdown tasks.
This control code enables the service to receive SERVICE_CONTROL_PRESHUTDOWN notifications. Note that ControlService and ControlServiceEx cannot send this notification; only the system can send it.
Windows Server 2003 and Windows XP:This value is not supported.
SERVICE_ACCEPT_SHUTDOWN
0x00000004 The service is notified when system shutdown occurs.
This control code allows the service to receive SERVICE_CONTROL_SHUTDOWN notifications. Note that ControlService and ControlServiceEx cannot send this notification; only the system can send it.
SERVICE_ACCEPT_STOP
0x00000001 The service can be stopped.
This control code allows the service to receive SERVICE_CONTROL_STOP notifications.