Search in sources :

Example 16 with SC_HANDLE

use of com.sun.jna.platform.win32.Winsvc.SC_HANDLE in project symmetric-ds by JumpMind.

the class WindowsService method isInstalled.

@Override
public boolean isInstalled() {
    Advapi32 advapi = Advapi32.INSTANCE;
    boolean isInstalled = false;
    SC_HANDLE manager = advapi.OpenSCManager(null, null, Winsvc.SC_MANAGER_ENUMERATE_SERVICE);
    if (manager == null) {
        throwException("OpenSCManager");
    } else {
        SC_HANDLE service = advapi.OpenService(manager, config.getName(), Winsvc.SERVICE_QUERY_STATUS);
        isInstalled = (service != null);
        closeServiceHandle(service);
        closeServiceHandle(manager);
    }
    return isInstalled;
}
Also used : SC_HANDLE(com.sun.jna.platform.win32.Winsvc.SC_HANDLE) Advapi32(com.sun.jna.platform.win32.Advapi32)

Aggregations

SC_HANDLE (com.sun.jna.platform.win32.Winsvc.SC_HANDLE)15 Advapi32 (com.sun.jna.platform.win32.Advapi32)3 SERVICE_STATUS_PROCESS (com.sun.jna.platform.win32.Winsvc.SERVICE_STATUS_PROCESS)3 IntByReference (com.sun.jna.ptr.IntByReference)3 Advapi32Ex (org.jumpmind.symmetric.wrapper.jna.Advapi32Ex)3 WString (com.sun.jna.WString)1 Winsvc (com.sun.jna.platform.win32.Winsvc)1 SERVICE_STATUS (com.sun.jna.platform.win32.Winsvc.SERVICE_STATUS)1 WinsvcEx (org.jumpmind.symmetric.wrapper.jna.WinsvcEx)1