BOOL ControlService( SC_HANDLE hService, // handle to service DWORD dwControl, // control code LPSERVICE_STATUS lpServiceStatus // status information ); dwControl 赋值为SERVICE_CONTROL_PAUSE 暂停 即 Notifies a service that it should pause. The hService handle must have SERVICE_PAUSE_CONTINUE access. SC_HANDLE CreateService( SC_HANDLE hSCManager, // handle to SCM database LPCTSTR lpServiceName, // name of service to start LPCTSTR lpDisplayName, // display name DWORD dwDesiredAccess, // type of access to service DWORD dwServiceType, // type of service DWORD dwStartType, // when to start service DWORD dwErrorControl, // severity of service failure LPCTSTR lpBinaryPathName, // name of binary file LPCTSTR lpLoadOrderGroup, // name of load ordering group LPDWORD lpdwTagId, // tag identifier LPCTSTR lpDependencies, // array of dependency names LPCTSTR lpServiceStartName, // account name LPCTSTR lpPassword // account password );dwStartType 赋值为SERVICE_AUTO_START 开机自动运行 即A service started automatically by the service control manager during system startup.
菜单资源如果没有关联消息映射,并添加相应函数,显示状态也是灰的。 解决办法是判断增加对暂停事件的响应: 大致思路是 if(ServiceControllerStatus.Paused==true) { // do something } 只是伪代码,具体用法楼主再查下。
SC_HANDLE hService, // handle to service
DWORD dwControl, // control code
LPSERVICE_STATUS lpServiceStatus // status information
);
dwControl 赋值为SERVICE_CONTROL_PAUSE 暂停
即 Notifies a service that it should pause. The hService handle must have SERVICE_PAUSE_CONTINUE access. SC_HANDLE CreateService(
SC_HANDLE hSCManager, // handle to SCM database
LPCTSTR lpServiceName, // name of service to start
LPCTSTR lpDisplayName, // display name
DWORD dwDesiredAccess, // type of access to service
DWORD dwServiceType, // type of service
DWORD dwStartType, // when to start service
DWORD dwErrorControl, // severity of service failure
LPCTSTR lpBinaryPathName, // name of binary file
LPCTSTR lpLoadOrderGroup, // name of load ordering group
LPDWORD lpdwTagId, // tag identifier
LPCTSTR lpDependencies, // array of dependency names
LPCTSTR lpServiceStartName, // account name
LPCTSTR lpPassword // account password
);dwStartType 赋值为SERVICE_AUTO_START 开机自动运行
即A service started automatically by the service control manager during system startup.
解决办法是判断增加对暂停事件的响应:
大致思路是
if(ServiceControllerStatus.Paused==true)
{
// do something
}
只是伪代码,具体用法楼主再查下。