Win32 API 日本語リファレンス
ホームSystem.Services › SERVICE_FAILURE_ACTIONS_FLAG

SERVICE_FAILURE_ACTIONS_FLAG

構造体
サイズx64: 4 バイト / x86: 4 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
fFailureActionsOnNonCrashFailuresBOOL4+0+0

このメンバーが TRUE で、サービスに障害時アクションが構成されている場合、サービス プロセスが SERVICE_STOPPED の状態を報告せずに終了したとき、または SERVICE_STOPPED 状態になったものの SERVICE_STATUS 構造体の dwWin32ExitCode メンバーが ERROR_SUCCESS (0) ではないときに、障害時アクションがキューに登録されます。

このメンバーが FALSE で、サービスに障害時アクションが構成されている場合、障害時アクションは、サービスが SERVICE_STOPPED の状態を報告せずに終了したときにのみキューに登録されます。

この設定は、サービスに障害時アクションが構成されていない限り無視されます。障害時アクションの構成については、ChangeServiceConfig2 を参照してください。

公式ドキュメント

サービスの障害時アクション フラグの設定を格納します。この設定は、障害時アクションをいつ実行するかを決定します。

解説(Remarks)

変更は、次回システムを起動したときに有効になります。

サービスに、回復できる可能性のある一般的な障害経路がある場合、このフラグを設定すると便利です。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での定義

#include <windows.h>

// SERVICE_FAILURE_ACTIONS_FLAG  (x64 4 / x86 4 バイト)
typedef struct SERVICE_FAILURE_ACTIONS_FLAG {
    BOOL fFailureActionsOnNonCrashFailures;
} SERVICE_FAILURE_ACTIONS_FLAG;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SERVICE_FAILURE_ACTIONS_FLAG
{
    [MarshalAs(UnmanagedType.Bool)] public bool fFailureActionsOnNonCrashFailures;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SERVICE_FAILURE_ACTIONS_FLAG
    <MarshalAs(UnmanagedType.Bool)> Public fFailureActionsOnNonCrashFailures As Boolean
End Structure
import ctypes
from ctypes import wintypes

class SERVICE_FAILURE_ACTIONS_FLAG(ctypes.Structure):
    _fields_ = [
        ("fFailureActionsOnNonCrashFailures", wintypes.BOOL),
    ]
#[repr(C)]
pub struct SERVICE_FAILURE_ACTIONS_FLAG {
    pub fFailureActionsOnNonCrashFailures: i32,
}
import "golang.org/x/sys/windows"

type SERVICE_FAILURE_ACTIONS_FLAG struct {
	fFailureActionsOnNonCrashFailures int32
}
type
  SERVICE_FAILURE_ACTIONS_FLAG = record
    fFailureActionsOnNonCrashFailures: BOOL;
  end;
const SERVICE_FAILURE_ACTIONS_FLAG = extern struct {
    fFailureActionsOnNonCrashFailures: i32,
};
type
  SERVICE_FAILURE_ACTIONS_FLAG {.bycopy.} = object
    fFailureActionsOnNonCrashFailures: int32
struct SERVICE_FAILURE_ACTIONS_FLAG
{
    int fFailureActionsOnNonCrashFailures;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SERVICE_FAILURE_ACTIONS_FLAG サイズ: 4 バイト(x64)
dim st, 1    ; 4byte整数×1(構造体サイズ 4 / 4 切り上げ)
; fFailureActionsOnNonCrashFailures : BOOL (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global SERVICE_FAILURE_ACTIONS_FLAG
    #field bool fFailureActionsOnNonCrashFailures
#endstruct

stdim st, SERVICE_FAILURE_ACTIONS_FLAG        ; NSTRUCT 変数を確保
st->fFailureActionsOnNonCrashFailures = 100
mes "fFailureActionsOnNonCrashFailures=" + st->fFailureActionsOnNonCrashFailures