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

SERVICE_STATUS

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

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

フィールド

フィールドサイズx64x86説明
dwServiceTypeENUM_SERVICE_TYPE4+0+0サービスの種類を示す ENUM_SERVICE_TYPE。独自プロセス/共有プロセス等。
dwCurrentStateSERVICE_STATUS_CURRENT_STATE4+4+4サービスの現在の状態を示す SERVICE_STATUS_CURRENT_STATE。実行中・停止等。
dwControlsAcceptedDWORD4+8+8サービスが受け付ける制御コードのフラグ集合(停止・一時停止等)。
dwWin32ExitCodeDWORD4+12+12サービス終了時の Win32 エラーコード。固有エラー時は ERROR_SERVICE_SPECIFIC_ERROR。
dwServiceSpecificExitCodeDWORD4+16+16サービス固有の終了コード。dwWin32ExitCode が固有エラーの場合に有効。
dwCheckPointDWORD4+20+20長時間操作の進捗を示す増分カウンター。
dwWaitHintDWORD4+24+24保留操作の完了見込み時間。ミリ秒単位。

各言語での定義

#include <windows.h>

// SERVICE_STATUS  (x64 28 / x86 28 バイト)
typedef struct SERVICE_STATUS {
    ENUM_SERVICE_TYPE dwServiceType;
    SERVICE_STATUS_CURRENT_STATE dwCurrentState;
    DWORD dwControlsAccepted;
    DWORD dwWin32ExitCode;
    DWORD dwServiceSpecificExitCode;
    DWORD dwCheckPoint;
    DWORD dwWaitHint;
} SERVICE_STATUS;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SERVICE_STATUS
{
    public uint dwServiceType;
    public uint dwCurrentState;
    public uint dwControlsAccepted;
    public uint dwWin32ExitCode;
    public uint dwServiceSpecificExitCode;
    public uint dwCheckPoint;
    public uint dwWaitHint;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SERVICE_STATUS
    Public dwServiceType As UInteger
    Public dwCurrentState As UInteger
    Public dwControlsAccepted As UInteger
    Public dwWin32ExitCode As UInteger
    Public dwServiceSpecificExitCode As UInteger
    Public dwCheckPoint As UInteger
    Public dwWaitHint As UInteger
End Structure
import ctypes
from ctypes import wintypes

class SERVICE_STATUS(ctypes.Structure):
    _fields_ = [
        ("dwServiceType", wintypes.DWORD),
        ("dwCurrentState", wintypes.DWORD),
        ("dwControlsAccepted", wintypes.DWORD),
        ("dwWin32ExitCode", wintypes.DWORD),
        ("dwServiceSpecificExitCode", wintypes.DWORD),
        ("dwCheckPoint", wintypes.DWORD),
        ("dwWaitHint", wintypes.DWORD),
    ]
#[repr(C)]
pub struct SERVICE_STATUS {
    pub dwServiceType: u32,
    pub dwCurrentState: u32,
    pub dwControlsAccepted: u32,
    pub dwWin32ExitCode: u32,
    pub dwServiceSpecificExitCode: u32,
    pub dwCheckPoint: u32,
    pub dwWaitHint: u32,
}
import "golang.org/x/sys/windows"

type SERVICE_STATUS struct {
	dwServiceType uint32
	dwCurrentState uint32
	dwControlsAccepted uint32
	dwWin32ExitCode uint32
	dwServiceSpecificExitCode uint32
	dwCheckPoint uint32
	dwWaitHint uint32
}
type
  SERVICE_STATUS = record
    dwServiceType: DWORD;
    dwCurrentState: DWORD;
    dwControlsAccepted: DWORD;
    dwWin32ExitCode: DWORD;
    dwServiceSpecificExitCode: DWORD;
    dwCheckPoint: DWORD;
    dwWaitHint: DWORD;
  end;
const SERVICE_STATUS = extern struct {
    dwServiceType: u32,
    dwCurrentState: u32,
    dwControlsAccepted: u32,
    dwWin32ExitCode: u32,
    dwServiceSpecificExitCode: u32,
    dwCheckPoint: u32,
    dwWaitHint: u32,
};
type
  SERVICE_STATUS {.bycopy.} = object
    dwServiceType: uint32
    dwCurrentState: uint32
    dwControlsAccepted: uint32
    dwWin32ExitCode: uint32
    dwServiceSpecificExitCode: uint32
    dwCheckPoint: uint32
    dwWaitHint: uint32
struct SERVICE_STATUS
{
    uint dwServiceType;
    uint dwCurrentState;
    uint dwControlsAccepted;
    uint dwWin32ExitCode;
    uint dwServiceSpecificExitCode;
    uint dwCheckPoint;
    uint dwWaitHint;
}

HSP用 定義

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

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

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