Search in sources :

Example 1 with SERVICE_FAILURE_ACTIONS_FLAG

use of com.sun.jna.platform.win32.Winsvc.SERVICE_FAILURE_ACTIONS_FLAG in project jna by java-native-access.

the class W32Service method setFailureActionsFlag.

/**
	 * Set the failure action flag of the specified service. Corresponds to 
	 * <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms681988.aspx">ChangeServiceConfig2</a>
	 * with parameter dwInfoLevel set to SERVICE_CONFIG_FAILURE_ACTIONS_FLAG. 
	 */
public void setFailureActionsFlag(boolean flagValue) {
    SERVICE_FAILURE_ACTIONS_FLAG flag = new SERVICE_FAILURE_ACTIONS_FLAG();
    flag.fFailureActionsOnNonCrashFailures = flagValue ? 1 : 0;
    if (!Advapi32.INSTANCE.ChangeServiceConfig2(_handle, Winsvc.SERVICE_CONFIG_FAILURE_ACTIONS_FLAG, flag)) {
        throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
    }
}
Also used : SERVICE_FAILURE_ACTIONS_FLAG(com.sun.jna.platform.win32.Winsvc.SERVICE_FAILURE_ACTIONS_FLAG)

Example 2 with SERVICE_FAILURE_ACTIONS_FLAG

use of com.sun.jna.platform.win32.Winsvc.SERVICE_FAILURE_ACTIONS_FLAG in project jna by java-native-access.

the class W32Service method getFailureActionsFlag.

/**
	 * Get the failure actions flag of the specified service. Corresponds to 
	 * <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms681988.aspx">QueryServiceConfig2</a>
	 * with parameter dwInfoLevel set to SERVICE_CONFIG_FAILURE_ACTIONS_FLAG. 
	 */
public boolean getFailureActionsFlag() {
    Pointer buffer = queryServiceConfig2(Winsvc.SERVICE_CONFIG_FAILURE_ACTIONS_FLAG);
    SERVICE_FAILURE_ACTIONS_FLAG result = new SERVICE_FAILURE_ACTIONS_FLAG(buffer);
    return result.fFailureActionsOnNonCrashFailures != 0;
}
Also used : SERVICE_FAILURE_ACTIONS_FLAG(com.sun.jna.platform.win32.Winsvc.SERVICE_FAILURE_ACTIONS_FLAG) Pointer(com.sun.jna.Pointer)

Aggregations

SERVICE_FAILURE_ACTIONS_FLAG (com.sun.jna.platform.win32.Winsvc.SERVICE_FAILURE_ACTIONS_FLAG)2 Pointer (com.sun.jna.Pointer)1