Top Description Fields Constructors Methods
com.sun.jna.platform.win32

public Class W32ServiceManager

extends Object
implements Closeable
Class Inheritance
All Implemented Interfaces
java.io.Closeable, java.lang.AutoCloseable
Imports
com.sun.jna.Memory, .Pointer, .Structure, com.sun.jna.platform.win32.Winsvc.ENUM_SERVICE_STATUS_PROCESS, .Winsvc.SC_HANDLE, com.sun.jna.ptr.IntByReference, java.io.Closeable

Win32 Service Manager wrapper
Author
EugineLev

Field Summary

Modifier and TypeField and Description
pack-priv String
pack-priv Winsvc.SC_HANDLE
pack-priv String

Constructor Summary

AccessConstructor and Description
public
W32ServiceManager()

Instantiate a W32ServiceManager for the local computer and the SERVICES_ACTIVE_DATABASE ("ServicesActive") database.

public
W32ServiceManager(int
requested permissions for access
permissions
)

Instantiate a W32ServiceManager for the local computer and the SERVICES_ACTIVE_DATABASE ("ServicesActive") database.

public
W32ServiceManager(String
The name of the target computer. If the pointer is NULL or points to an empty string, the function connects to the service control manager on the local computer.
machineName
,
String
The name of the service control manager database. This parameter should be set to "ServicesActive". If it is NULL, the "ServicesActive" (SERVICES_ACTIVE_DATABASE) database is opened by default.

The connection is not established until open(int) is called.

databaseName
)

Instantiate a W32ServiceManager.

public
W32ServiceManager(String
The name of the target computer. If the pointer is NULL or points to an empty string, the function connects to the service control manager on the local computer.
machineName
,
String
The name of the service control manager database. This parameter should be set to "ServicesActive". If it is NULL, the "ServicesActive" (SERVICES_ACTIVE_DATABASE) database is opened by default.
databaseName
,
int
requested permissions for access
permissions
)

Instantiate a W32ServiceManager.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.io.Closeable.close.

Closes the previously opened Service Manager.
public Winsvc.ENUM_SERVICE_STATUS_PROCESS[]

Returns:

array of ENUM_SERVICE_STATUS_PROCESS structures.
enumServicesStatusExProcess
(int
The type of services to be enumerated. This parameter can be one or more of the following values.
ValueMeaning
WinNT#SERVICE_DRIVERServices of type WinNT#SERVICE_KERNEL_DRIVER and WinNT#SERVICE_FILE_SYSTEM_DRIVER.
WinNT#SERVICE_FILE_SYSTEM_DRIVERFile system driver services.
WinNT#SERVICE_KERNEL_DRIVERDriver services.
WinNT#SERVICE_WIN32Services of type WinNT#SERVICE_WIN32_OWN_PROCESS and WinNT#SERVICE_WIN32_SHARE_PROCESS.
WinNT#SERVICE_WIN32_OWN_PROCESSServices that run in their own processes.
WinNT#SERVICE_WIN32_SHARE_PROCESSServices that share a process with one or more other services. For more information, see Service Programs.
dwServiceType
,
int
The state of the services to be enumerated. This parameter can be one of the following values.
ValueMeaning
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, and Winsvc#SERVICE_PAUSED.
Winsvc#SERVICE_INACTIVEEnumerates services that are in the Winsvc#SERVICE_STOPPED state.
Winsvc#SERVICE_STATE_ALLCombines the following states: Winsvc#SERVICE_ACTIVE and Winsvc#SERVICE_INACTIVE.
dwServiceState
,
String
The load-order group name. If this parameter is a string, the only services enumerated are those that belong to the group that has the name specified by the string. If this parameter is an empty string, only services that do not belong to any group are enumerated. If this parameter is NULL, group membership is ignored and all services are enumerated.
groupName
)

Enumerates services in the specified service control manager database.

public Winsvc.SC_HANDLE

Returns:

Returns the service manager handle.
getHandle
()

Gets the service manager handle.

public void
open(int
Permissions.
permissions
)

(Re-)Opens the Service Manager with the supplied permissions.

public W32Service

Returns:

Returns an opened service.
openService
(String
Service name.
serviceName
,
int
Permissions.
permissions
)

Opens a Service.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_databaseNameback to summary
pack-priv String _databaseName
_handleback to summary
pack-priv Winsvc.SC_HANDLE _handle
_machineNameback to summary
pack-priv String _machineName

Constructor Detail

W32ServiceManagerback to summary
public W32ServiceManager()

Instantiate a W32ServiceManager for the local computer and the SERVICES_ACTIVE_DATABASE ("ServicesActive") database.

The connection is not established until open(int) is called.

W32ServiceManagerback to summary
public W32ServiceManager(int permissions)

Instantiate a W32ServiceManager for the local computer and the SERVICES_ACTIVE_DATABASE ("ServicesActive") database.

A connection is opened directly with the requested permissions.

Parameters
permissions:int

requested permissions for access

W32ServiceManagerback to summary
public W32ServiceManager(String machineName, String databaseName)

Instantiate a W32ServiceManager.

Parameters
machineName:String

The name of the target computer. If the pointer is NULL or points to an empty string, the function connects to the service control manager on the local computer.

databaseName:String

The name of the service control manager database. This parameter should be set to "ServicesActive". If it is NULL, the "ServicesActive" (SERVICES_ACTIVE_DATABASE) database is opened by default.

The connection is not established until open(int) is called.

W32ServiceManagerback to summary
public W32ServiceManager(String machineName, String databaseName, int permissions)

Instantiate a W32ServiceManager.

A connection is opened directly with the requested permissions.

Parameters
machineName:String

The name of the target computer. If the pointer is NULL or points to an empty string, the function connects to the service control manager on the local computer.

databaseName:String

The name of the service control manager database. This parameter should be set to "ServicesActive". If it is NULL, the "ServicesActive" (SERVICES_ACTIVE_DATABASE) database is opened by default.

permissions:int

requested permissions for access

Method Detail

closeback to summary
public void close()

Implements java.io.Closeable.close.

Closes the previously opened Service Manager.

Annotations
@Override
enumServicesStatusExProcessback to summary
public Winsvc.ENUM_SERVICE_STATUS_PROCESS[] enumServicesStatusExProcess(int dwServiceType, int dwServiceState, String groupName)

Enumerates services in the specified service control manager database. The name and status of each service are provided, along with additional data based on the specified information level.

Parameters
dwServiceType:int

The type of services to be enumerated. This parameter can be one or more of the following values.

ValueMeaning
WinNT#SERVICE_DRIVERServices of type WinNT#SERVICE_KERNEL_DRIVER and WinNT#SERVICE_FILE_SYSTEM_DRIVER.
WinNT#SERVICE_FILE_SYSTEM_DRIVERFile system driver services.
WinNT#SERVICE_KERNEL_DRIVERDriver services.
WinNT#SERVICE_WIN32Services of type WinNT#SERVICE_WIN32_OWN_PROCESS and WinNT#SERVICE_WIN32_SHARE_PROCESS.
WinNT#SERVICE_WIN32_OWN_PROCESSServices that run in their own processes.
WinNT#SERVICE_WIN32_SHARE_PROCESSServices that share a process with one or more other services. For more information, see Service Programs.
dwServiceState:int

The state of the services to be enumerated. This parameter can be one of the following values.

ValueMeaning
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, and Winsvc#SERVICE_PAUSED.
Winsvc#SERVICE_INACTIVEEnumerates services that are in the Winsvc#SERVICE_STOPPED state.
Winsvc#SERVICE_STATE_ALLCombines the following states: Winsvc#SERVICE_ACTIVE and Winsvc#SERVICE_INACTIVE.
groupName:String

The load-order group name. If this parameter is a string, the only services enumerated are those that belong to the group that has the name specified by the string. If this parameter is an empty string, only services that do not belong to any group are enumerated. If this parameter is NULL, group membership is ignored and all services are enumerated.

Returns:Winsvc.ENUM_SERVICE_STATUS_PROCESS[]

array of ENUM_SERVICE_STATUS_PROCESS structures.

getHandleback to summary
public Winsvc.SC_HANDLE getHandle()

Gets the service manager handle.

Returns:Winsvc.SC_HANDLE

Returns the service manager handle.

openback to summary
public void open(int permissions)

(Re-)Opens the Service Manager with the supplied permissions.

Parameters
permissions:int

Permissions.

openServiceback to summary
public W32Service openService(String serviceName, int permissions)

Opens a Service.

Parameters
serviceName:String

Service name.

permissions:int

Permissions.

Returns:W32Service

Returns an opened service.