Interface Win32Service
-
- All Superinterfaces:
Service
public interface Win32Service extends Service
This service provides a variety of methods for interacting with Win32 specific capabilities, including:- Windows NT Services
- Windows-specific file system API's
In each method, if any Win32 API's return an error code, the method throws a ServiceException containing a description of the error as reported by Win32. This description ends with the actual error code displayed in parentheses.
For NT services methods, all Win32 calls use the SERVICES_ACTIVE_DATABASE on the local machine when opening a handle to the service control manager.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
NAME
static int
SERVICE_ACTIVE
Can be used for the serviceState parameter in a call to enumNTServiceKeysstatic int
SERVICE_CONTROL_CONTINUE
Can be used for the control parameter in a call to controlNTServicestatic int
SERVICE_CONTROL_INTERROGATE
Can be used for the control parameter in a call to controlNTServicestatic int
SERVICE_CONTROL_NETBINDADD
Can be used for the control parameter in a call to controlNTService.static int
SERVICE_CONTROL_NETBINDDISABLE
Can be used for the control parameter in a call to controlNTService.static int
SERVICE_CONTROL_NETBINDENABLE
Can be used for the control parameter in a call to controlNTService.static int
SERVICE_CONTROL_NETBINDREMOVE
Can be used for the control parameter in a call to controlNTService.static int
SERVICE_CONTROL_PARAMCHANGE
Can be used for the control parameter in a call to controlNTService.static int
SERVICE_CONTROL_PAUSE
Can be used for the control parameter in a call to controlNTServicestatic int
SERVICE_CONTROL_STOP
Can be used for the control parameter in a call to controlNTServicestatic int
SERVICE_DRIVER
Can be used for the serviceType parameter in a call to enumNTServiceKeysstatic int
SERVICE_INACTIVE
Can be used for the serviceState parameter in a call to enumNTServiceKeysstatic int
SERVICE_STATE_ALL
Can be used for the serviceState parameter in a call to enumNTServiceKeysstatic int
SERVICE_WIN32
Can be used for the serviceType parameter in a call to enumNTServiceKeys
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
changeNTServiceConfig(java.lang.String name, NTServiceConfig serviceConfig)
Calls the Win32 ChangeServiceConfig API to update the configuration of the specified service.void
changeWin2kServiceDescription(java.lang.String name, java.lang.String description)
Calls the Win32 ChangeServiceConfig2 API in order to update the description of the service.void
changeWin2kServiceFailureActions(java.lang.String name, Win2kServiceFailureActions serviceFailureActions)
Calls the Win32 ChangeServiceConfig2 API in order to update the failure actions of the service.NTServiceStatus
controlNTService(java.lang.String name, int control)
Calls the Win32 ControlService API to send a control code to the specified service.void
createNTService(java.lang.String name, NTServiceConfig serviceConfig)
Creates a new service on Windows NT and 2K machines.void
deleteNTService(java.lang.String name)
Calls the Win32 DeleteService API to delete the specified service.java.lang.String[]
enumNTServiceKeys(int serviceType, int serviceState)
Calls the Win32 EnumServicesStatus API to retrieve the internal names of of each service defined in the active service control manager database.WindowsFixedFileInfo
getFixedFileInfo(java.lang.String fileName)
Retrieves Windows VS_FIXEDFILEINFO of the specified file.java.lang.String
getNTServiceDisplayName(java.lang.String name)
Calls the Win32 GetServiceDisplayName API to retrieve the displayable name of the specified service.java.lang.String
getNTServiceKeyName(java.lang.String displayName)
Calls the Win32 GetServiceKeyName API to retrieve the internal name of a service based on its display name.java.lang.String
getShortPath(java.lang.String longPath)
Returns the short path name for a long path passed in.boolean
isWin2k()
Returns true if the target machine is Windows 2000, otherwise returns false.NTServiceConfig
queryNTServiceConfig(java.lang.String name)
Calls the Win32 QueryServiceConfig API to request the currrent configuration of the specified service.NTServiceStatus
queryNTServiceStatus(java.lang.String name)
Calls the Win32 QueryServiceStatus to retrieve the status of the specified service.java.lang.String
queryWin2kServiceDescription(java.lang.String name)
Calls the Win32 QueryServiceConfig2 API to get the description for the specified service.Win2kServiceFailureActions
queryWin2kServiceFailureActions(java.lang.String name)
Calls the Win32 QueryServiceConfig2 API to get the failure actions for the specified service.Win2kServiceStatusProcess
queryWin2kServiceStatusProcess(java.lang.String name)
Calls the Win32 QueryServiceStatusEx API to retrieve the service status information including information about the service's process.boolean
serviceExists(java.lang.String name)
Queries the Win32 Service Control Manager to determine if the specified service exists.void
startNTService(java.lang.String name, java.lang.String[] args)
Calls the Win32 StartService API to start the specified service.-
Methods inherited from interface com.installshield.wizard.service.Service
cancelOperation, getName, getOperationProgress, getServiceImplementorType, isNoopMode, isOperationCanceled, isOperationEnded, isOperationSuspended, resumeOperation, setNoopMode, suspendOperation
-
-
-
-
Field Detail
-
NAME
static final java.lang.String NAME
-
SERVICE_CONTROL_CONTINUE
static final int SERVICE_CONTROL_CONTINUE
Can be used for the control parameter in a call to controlNTService- See Also:
- Constant Field Values
-
SERVICE_CONTROL_INTERROGATE
static final int SERVICE_CONTROL_INTERROGATE
Can be used for the control parameter in a call to controlNTService- See Also:
- Constant Field Values
-
SERVICE_CONTROL_NETBINDADD
static final int SERVICE_CONTROL_NETBINDADD
Can be used for the control parameter in a call to controlNTService. This can only be used on Win2K or later.- See Also:
- Constant Field Values
-
SERVICE_CONTROL_NETBINDDISABLE
static final int SERVICE_CONTROL_NETBINDDISABLE
Can be used for the control parameter in a call to controlNTService. This can only be used on Win2K or later.- See Also:
- Constant Field Values
-
SERVICE_CONTROL_NETBINDENABLE
static final int SERVICE_CONTROL_NETBINDENABLE
Can be used for the control parameter in a call to controlNTService. This can only be used on Win2K or later.- See Also:
- Constant Field Values
-
SERVICE_CONTROL_NETBINDREMOVE
static final int SERVICE_CONTROL_NETBINDREMOVE
Can be used for the control parameter in a call to controlNTService. This can only be used on Win2K or later.- See Also:
- Constant Field Values
-
SERVICE_CONTROL_PARAMCHANGE
static final int SERVICE_CONTROL_PARAMCHANGE
Can be used for the control parameter in a call to controlNTService. This can only be used on Win2K or later.- See Also:
- Constant Field Values
-
SERVICE_CONTROL_PAUSE
static final int SERVICE_CONTROL_PAUSE
Can be used for the control parameter in a call to controlNTService- See Also:
- Constant Field Values
-
SERVICE_CONTROL_STOP
static final int SERVICE_CONTROL_STOP
Can be used for the control parameter in a call to controlNTService- See Also:
- Constant Field Values
-
SERVICE_WIN32
static final int SERVICE_WIN32
Can be used for the serviceType parameter in a call to enumNTServiceKeys- See Also:
- Constant Field Values
-
SERVICE_DRIVER
static final int SERVICE_DRIVER
Can be used for the serviceType parameter in a call to enumNTServiceKeys- See Also:
- Constant Field Values
-
SERVICE_ACTIVE
static final int SERVICE_ACTIVE
Can be used for the serviceState parameter in a call to enumNTServiceKeys- See Also:
- Constant Field Values
-
SERVICE_INACTIVE
static final int SERVICE_INACTIVE
Can be used for the serviceState parameter in a call to enumNTServiceKeys- See Also:
- Constant Field Values
-
SERVICE_STATE_ALL
static final int SERVICE_STATE_ALL
Can be used for the serviceState parameter in a call to enumNTServiceKeys- See Also:
- Constant Field Values
-
-
Method Detail
-
createNTService
void createNTService(java.lang.String name, NTServiceConfig serviceConfig) throws ServiceException
Creates a new service on Windows NT and 2K machines. This corresponds directly to the CreateService Win32 API. The parameters passed to CreateService are obtained from properties set within the NTServiceConfig objectc passed in.- Parameters:
name
- The internal name of the service. Maps to the lpServiceName parameter of the CreateServiceAPI.serviceConfig
- Contains values with which the new service is configured.- Throws:
ServiceException
-
deleteNTService
void deleteNTService(java.lang.String name) throws ServiceException
Calls the Win32 DeleteService API to delete the specified service. See the Win32 API documentation for details on that API.- Parameters:
name
- The internal name of the service to be deleted. This name is used in a call to the Win32 OpenService API to get a handle to the service, which is then passed to DeleteService.- Throws:
ServiceException
-
startNTService
void startNTService(java.lang.String name, java.lang.String[] args) throws ServiceException
Calls the Win32 StartService API to start the specified service. The arguments specified in the args parameter are passed into the StartService API.- Parameters:
name
- The internal name of the service to start. This value is passed to the OpenService Win32 API to get a handle to the service being started.args
- The arguments to be passed to the StartService API. This argument can either be an empty array or null if no arguments are to be passed.- Throws:
ServiceException
-
changeNTServiceConfig
void changeNTServiceConfig(java.lang.String name, NTServiceConfig serviceConfig) throws ServiceException
Calls the Win32 ChangeServiceConfig API to update the configuration of the specified service.- Parameters:
name
- The internal name of the service for which to change configuration.serviceConfig
- Contains the new configuration settings for the service.- Throws:
ServiceException
-
changeWin2kServiceDescription
void changeWin2kServiceDescription(java.lang.String name, java.lang.String description) throws ServiceException
Calls the Win32 ChangeServiceConfig2 API in order to update the description of the service. It uses SERVICE_CONFIG_DESCRIPTION for the info level parameter when it calls ChangeServiceConfig2. See the Win32 documentation for this API for more information. This only works on Windows 2000.- Parameters:
name
- The internal name of the service for which to change the description.description
- The description to assign to the service.- Throws:
ServiceException
-
changeWin2kServiceFailureActions
void changeWin2kServiceFailureActions(java.lang.String name, Win2kServiceFailureActions serviceFailureActions) throws ServiceException
Calls the Win32 ChangeServiceConfig2 API in order to update the failure actions of the service. It uses SERVICE_CONFIG_FAILURE_ACTIONS for the info level parameter when it calls ChangeServiceConfig2. See the Win32 documentation for this API for more information. This only works on Win 2000.- Parameters:
name
- The internal name of the service for which to setup failure actions.serviceFailureActions
- The failure actions to setup for the service.- Throws:
ServiceException
-
controlNTService
NTServiceStatus controlNTService(java.lang.String name, int control) throws ServiceException
Calls the Win32 ControlService API to send a control code to the specified service. See the Win32 documentation for this API for more information.- Parameters:
name
- The internal name of the service to which to send a control code.control
- The control code to send to the service.- Returns:
- The status of the service.
- Throws:
ServiceException
-
queryNTServiceConfig
NTServiceConfig queryNTServiceConfig(java.lang.String name) throws ServiceException
Calls the Win32 QueryServiceConfig API to request the currrent configuration of the specified service. See the Win32 documentation for this API for more information.- Parameters:
name
- The name of the service for which to return configuration information.- Throws:
ServiceException
-
queryWin2kServiceDescription
java.lang.String queryWin2kServiceDescription(java.lang.String name) throws ServiceException
Calls the Win32 QueryServiceConfig2 API to get the description for the specified service. It passes SERVICE_CONFIG_DESCRIPTION for the info level parameter to that API. This only works on Windows 2000. See the Win32 documentation for this API for more information.- Parameters:
name
- The internal name of the service for which to get the description.- Throws:
ServiceException
-
queryWin2kServiceFailureActions
Win2kServiceFailureActions queryWin2kServiceFailureActions(java.lang.String name) throws ServiceException
Calls the Win32 QueryServiceConfig2 API to get the failure actions for the specified service. It passes SERVICE_CONFIG_FAILURE_ACTIONS for the info level parameter to that API. This only works on Windows 2000. See the Win32 documentation for this API for more information.- Parameters:
name
- The internal name of the service for which to get the failure actions.- Throws:
ServiceException
-
getNTServiceDisplayName
java.lang.String getNTServiceDisplayName(java.lang.String name) throws ServiceException
Calls the Win32 GetServiceDisplayName API to retrieve the displayable name of the specified service. See the Win32 documentation for this API for more information.- Parameters:
name
- The internal name of the service.- Throws:
ServiceException
-
getNTServiceKeyName
java.lang.String getNTServiceKeyName(java.lang.String displayName) throws ServiceException
Calls the Win32 GetServiceKeyName API to retrieve the internal name of a service based on its display name. See the Win32 documentation for this API for more information.- Parameters:
displayName
- The display name of the service.- Throws:
ServiceException
-
enumNTServiceKeys
java.lang.String[] enumNTServiceKeys(int serviceType, int serviceState) throws ServiceException
Calls the Win32 EnumServicesStatus API to retrieve the internal names of of each service defined in the active service control manager database. See the Win32 documentation for this API for more information.- Parameters:
serviceType
- The type of services to enumerate. This should be set to either SERVICE_WIN32 or SERVICE_DRIVER.serviceState
- The state of services to enumerate. This should be set to SERVICE_ACTIVE, SERVICE_INACTIVE or SERVICE_STATE_ALL.- Returns:
- An array of internal service names.
- Throws:
ServiceException
-
queryNTServiceStatus
NTServiceStatus queryNTServiceStatus(java.lang.String name) throws ServiceException
Calls the Win32 QueryServiceStatus to retrieve the status of the specified service. See the Win32 documentation for this API for more information.- Parameters:
name
- The internal name of the service.- Throws:
ServiceException
-
queryWin2kServiceStatusProcess
Win2kServiceStatusProcess queryWin2kServiceStatusProcess(java.lang.String name) throws ServiceException
Calls the Win32 QueryServiceStatusEx API to retrieve the service status information including information about the service's process. It passes SC_STATUS_PROCESS_INFO for the info level parameter to get process status data. This only works on Windows 2000. See the Win32 documentation for this API for more information.- Parameters:
name
- The internal name of the service for which to retrieve process status data.- Throws:
ServiceException
-
serviceExists
boolean serviceExists(java.lang.String name) throws ServiceException
Queries the Win32 Service Control Manager to determine if the specified service exists.- Parameters:
name
- The internal name of the service to check.- Throws:
ServiceException
-
isWin2k
boolean isWin2k() throws ServiceException
Returns true if the target machine is Windows 2000, otherwise returns false.- Returns:
- True if the target machine is Windows 2000
- Throws:
ServiceException
-
getShortPath
java.lang.String getShortPath(java.lang.String longPath) throws ServiceException
Returns the short path name for a long path passed in.- Parameters:
longPath
- A long path on the target machine for which to retrieve the short path.- Throws:
ServiceException
-
getFixedFileInfo
WindowsFixedFileInfo getFixedFileInfo(java.lang.String fileName) throws ServiceException
Retrieves Windows VS_FIXEDFILEINFO of the specified file. If the specified file does not exist, a ServiceException is thrown. If the file does not contain version info, this method returns null.- Parameters:
fileName
- The name of the file for which to fetch Windows fixed file info.- Returns:
- A WindowsFixedFileInfo object containing the data from the Windows VS_FIXEDFILEINFO structure, or null if the file does not contain file info.
- Throws:
ServiceException
-
-