Package com.sun.jna.platform.win32
Class W32Service
- java.lang.Object
-
- com.sun.jna.platform.win32.W32Service
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class W32Service extends java.lang.Object implements java.io.CloseableWin32 Service wrapper- Author:
- EugineLev
-
-
Field Summary
Fields Modifier and Type Field Description (package private) Winsvc.SC_HANDLE_handle
-
Constructor Summary
Constructors Constructor Description W32Service(Winsvc.SC_HANDLE handle)Win32 Service
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close service.voidcontinueService()Continue service.Winsvc.ENUM_SERVICE_STATUS[]enumDependentServices(int dwServiceState)Retrieves the name and status of each service that depends on the specified service; that is, the specified service must be running before the dependent services can run.Winsvc.SERVICE_FAILURE_ACTIONSgetFailureActions()Get the failure actions of the specified service.booleangetFailureActionsFlag()Get the failure actions flag of the specified service.Winsvc.SC_HANDLEgetHandle()Gets the service handle.voidpauseService()Pause service.Winsvc.SERVICE_STATUS_PROCESSqueryStatus()Retrieves the current status of the specified service based on the specified information level.(package private) intsanitizeWaitTime(int dwWaitHint)do not wait longer than the wait hint.voidsetFailureActions(java.util.List<Winsvc.SC_ACTION> actions, int resetPeriod, java.lang.String rebootMsg, java.lang.String command)Set the failure actions of the specified service.voidsetFailureActionsFlag(boolean flagValue)Set the failure action flag of the specified service.voidstartService()voidstopService()Stop service.voidstopService(long timeout)Stop service.voidwaitForNonPendingState()Wait for the state to change to something other than a pending state.
-
-
-
Field Detail
-
_handle
Winsvc.SC_HANDLE _handle
-
-
Constructor Detail
-
W32Service
public W32Service(Winsvc.SC_HANDLE handle)
Win32 Service- Parameters:
handle- A handle to the service. This handle is returned by the CreateService or OpenService function, and it must have the SERVICE_QUERY_STATUS access right.
-
-
Method Detail
-
close
public void close()
Close service.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
setFailureActions
public void setFailureActions(java.util.List<Winsvc.SC_ACTION> actions, int resetPeriod, java.lang.String rebootMsg, java.lang.String command)
Set the failure actions of the specified service. Corresponds to ChangeServiceConfig2 with parameter dwInfoLevel set to SERVICE_CONFIG_FAILURE_ACTIONS.
-
getFailureActions
public Winsvc.SERVICE_FAILURE_ACTIONS getFailureActions()
Get the failure actions of the specified service. Corresponds to QueryServiceConfig2 with parameter dwInfoLevel set to SERVICE_CONFIG_FAILURE_ACTIONS.
-
setFailureActionsFlag
public void setFailureActionsFlag(boolean flagValue)
Set the failure action flag of the specified service. Corresponds to ChangeServiceConfig2 with parameter dwInfoLevel set to SERVICE_CONFIG_FAILURE_ACTIONS_FLAG.
-
getFailureActionsFlag
public boolean getFailureActionsFlag()
Get the failure actions flag of the specified service. Corresponds to QueryServiceConfig2 with parameter dwInfoLevel set to SERVICE_CONFIG_FAILURE_ACTIONS_FLAG.
-
queryStatus
public Winsvc.SERVICE_STATUS_PROCESS queryStatus()
Retrieves the current status of the specified service based on the specified information level.- Returns:
- Service status information
-
startService
public void startService()
-
stopService
public void stopService()
Stop service.
-
stopService
public void stopService(long timeout)
Stop service.- Parameters:
timeout- timeout in ms until the service must report to be stopped
-
continueService
public void continueService()
Continue service.
-
pauseService
public void pauseService()
Pause service.
-
sanitizeWaitTime
int sanitizeWaitTime(int dwWaitHint)
do not wait longer than the wait hint. A good interval is one-tenth the wait hint, but no less than 1 second and no more than 10 seconds.
-
waitForNonPendingState
public void waitForNonPendingState()
Wait for the state to change to something other than a pending state.
-
getHandle
public Winsvc.SC_HANDLE getHandle()
Gets the service handle.- Returns:
- Returns the service handle.
-
enumDependentServices
public Winsvc.ENUM_SERVICE_STATUS[] enumDependentServices(int dwServiceState)
Retrieves the name and status of each service that depends on the specified service; that is, the specified service must be running before the dependent services can run.- Parameters:
dwServiceState- The state of the services to be enumerated. This parameter can be one of the following values.Value Meaning Winsvc.SERVICE_ACTIVEEnumerates services that are in the following states: Winsvc.SERVICE_START_PENDING,Winsvc.SERVICE_STOP_PENDING,Winsvc.SERVICE_RUNNING,Winsvc.SERVICE_CONTINUE_PENDING,Winsvc.SERVICE_PAUSE_PENDING, andWinsvc.SERVICE_PAUSED.Winsvc.SERVICE_INACTIVEEnumerates services that are in the Winsvc.SERVICE_STOPPEDstate.Winsvc.SERVICE_STATE_ALLCombines the following states: Winsvc.SERVICE_ACTIVEandWinsvc.SERVICE_INACTIVE.- Returns:
- array of ENUM_SERVICE_STATUS structures that receives the name and service status information for each dependent service in the database.
-
-