Package com.sun.jna.platform.win32
Class W32Service
java.lang.Object
com.sun.jna.platform.win32.W32Service
- All Implemented Interfaces:
- Closeable,- AutoCloseable
Win32 Service wrapper
- Author:
- EugineLev
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()Close service.voidContinue service.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.Get the failure actions of the specified service.booleanGet the failure actions flag of the specified service.Gets the service handle.voidPause service.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(List<Winsvc.SC_ACTION> actions, int resetPeriod, String rebootMsg, String command) Set the failure actions of the specified service.voidsetFailureActionsFlag(boolean flagValue) Set the failure action flag of the specified service.voidvoidStop service.voidstopService(long timeout) Stop service.voidWait for the state to change to something other than a pending state.
- 
Field Details- 
_handleWinsvc.SC_HANDLE _handle
 
- 
- 
Constructor Details- 
W32ServiceWin32 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 Details- 
closepublic void close()Close service.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
 
- 
setFailureActionspublic void setFailureActions(List<Winsvc.SC_ACTION> actions, int resetPeriod, String rebootMsg, String command) Set the failure actions of the specified service. Corresponds to ChangeServiceConfig2 with parameter dwInfoLevel set to SERVICE_CONFIG_FAILURE_ACTIONS.
- 
getFailureActionsGet the failure actions of the specified service. Corresponds to QueryServiceConfig2 with parameter dwInfoLevel set to SERVICE_CONFIG_FAILURE_ACTIONS.
- 
setFailureActionsFlagpublic 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.
- 
getFailureActionsFlagpublic boolean getFailureActionsFlag()Get the failure actions flag of the specified service. Corresponds to QueryServiceConfig2 with parameter dwInfoLevel set to SERVICE_CONFIG_FAILURE_ACTIONS_FLAG.
- 
queryStatusRetrieves the current status of the specified service based on the specified information level.- Returns:
- Service status information
 
- 
startServicepublic void startService()
- 
stopServicepublic void stopService()Stop service.
- 
stopServicepublic void stopService(long timeout) Stop service.- Parameters:
- timeout- timeout in ms until the service must report to be stopped
 
- 
continueServicepublic void continueService()Continue service.
- 
pauseServicepublic void pauseService()Pause service.
- 
sanitizeWaitTimeint 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.
- 
waitForNonPendingStatepublic void waitForNonPendingState()Wait for the state to change to something other than a pending state.
- 
getHandleGets the service handle.- Returns:
- Returns the service handle.
 
- 
enumDependentServicesRetrieves 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_ACTIVE- Enumerates 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, and- Winsvc.SERVICE_PAUSED.- Winsvc.SERVICE_INACTIVE- Enumerates services that are in the - Winsvc.SERVICE_STOPPEDstate.- Winsvc.SERVICE_STATE_ALL- Combines the following states: - Winsvc.SERVICE_ACTIVEand- Winsvc.SERVICE_INACTIVE.
- Returns:
- array of ENUM_SERVICE_STATUS structures that receives the name and service status information for each dependent service in the database.
 
 
-