public boolean start() { boolean success = false; SC_HANDLE serviceManager = openServiceControlManager(null, WinNT.GENERIC_EXECUTE); if (serviceManager != null) { SC_HANDLE service = ADVAPI_32.OpenService(serviceManager, serviceName, WinNT.GENERIC_EXECUTE); if (service != null) { success = ADVAPI_32.StartService(service, 0, null); ADVAPI_32.CloseServiceHandle(service); } ADVAPI_32.CloseServiceHandle(serviceManager); } return success; }
public boolean uninstall() { boolean success = false; SC_HANDLE serviceManager = openServiceControlManager(null, Winsvc.SC_MANAGER_ALL_ACCESS); if (serviceManager != null) { SC_HANDLE service = ADVAPI_32.OpenService(serviceManager, serviceName, Winsvc.SERVICE_ALL_ACCESS); if (service != null) { success = ADVAPI_32.DeleteService(service); ADVAPI_32.CloseServiceHandle(service); } ADVAPI_32.CloseServiceHandle(serviceManager); } return success; }
public boolean stop() { boolean success = false; SC_HANDLE serviceManager = openServiceControlManager(null, WinNT.GENERIC_EXECUTE); if (serviceManager != null) { SC_HANDLE service = Advapi32.INSTANCE.OpenService(serviceManager, serviceName, WinNT.GENERIC_EXECUTE); if (service != null) { SERVICE_STATUS serviceStatus = new SERVICE_STATUS(); success = Advapi32.INSTANCE.ControlService(service, Winsvc.SERVICE_CONTROL_STOP, serviceStatus); Advapi32.INSTANCE.CloseServiceHandle(service); } Advapi32.INSTANCE.CloseServiceHandle(serviceManager); } return success; }
ADVAPI_32.CloseServiceHandle(service); ADVAPI_32.CloseServiceHandle(serviceManager);
/** * Close service. */ @Override public void close() { if (_handle != null) { if (! Advapi32.INSTANCE.CloseServiceHandle(_handle)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } _handle = null; } }
/** * Closes the previously opened Service Manager. */ @Override public void close() { if (_handle != null) { if (! Advapi32.INSTANCE.CloseServiceHandle(_handle)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } _handle = null; } }
/** * Closes the previously opened Service Manager. */ public void close() { if (_handle != null) { if (! Advapi32.INSTANCE.CloseServiceHandle(_handle)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } _handle = null; } }
/** * Close service. */ public void close() { if (_handle != null) { if (! Advapi32.INSTANCE.CloseServiceHandle(_handle)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } _handle = null; } }