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

ENUM_SERVICE_STATUSW

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

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

フィールド

フィールドサイズx64x86説明
lpServiceNameLPWSTR8/4+0+0サービス コントロール マネージャー データベース内のサービスの名前です。文字列の最大長は 256 文字です。サービス コントロール マネージャー データベースは文字の大文字と小文字を保持しますが、サービス名の比較は常に大文字と小文字を区別しません。スラッシュ (/)、円記号 (\)、コンマ、およびスペースは、サービス名として無効な文字です。
lpDisplayNameLPWSTR8/4+8+4コントロール パネルの [サービス] など、サービス制御プログラムがサービスを識別するために使用できる表示名です。この文字列の最大長は 256 文字です。名前はサービス コントロール マネージャー内で大文字と小文字が保持されます。表示名の比較は常に大文字と小文字を区別しません。
ServiceStatusSERVICE_STATUS28+16+8lpServiceName のサービスの状態情報を格納する SERVICE_STATUS 構造体です。

公式ドキュメント

サービス コントロール マネージャー データベース内のサービスの名前と、そのサービスに関する情報を格納します。 EnumDependentServices 関数および EnumServicesStatus 関数で使用されます。

解説(Remarks)

メモ

winsvc.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版と Unicode 版を自動的に選択するエイリアスとして ENUM_SERVICE_STATUS を定義しています。エンコーディング中立のエイリアスと、エンコーディング中立でないコードを混在させて使用すると、不整合が生じてコンパイル エラーや実行時エラーの原因となることがあります。詳細については、関数プロトタイプの規則 を参照してください。

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

各言語での定義

#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;

// ENUM_SERVICE_STATUSW  (x64 48 / x86 36 バイト)
typedef struct ENUM_SERVICE_STATUSW {
    LPWSTR lpServiceName;
    LPWSTR lpDisplayName;
    SERVICE_STATUS ServiceStatus;
} ENUM_SERVICE_STATUSW;
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;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ENUM_SERVICE_STATUSW
{
    public IntPtr lpServiceName;
    public IntPtr lpDisplayName;
    public SERVICE_STATUS ServiceStatus;
}
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

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure ENUM_SERVICE_STATUSW
    Public lpServiceName As IntPtr
    Public lpDisplayName As IntPtr
    Public ServiceStatus As SERVICE_STATUS
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),
    ]

class ENUM_SERVICE_STATUSW(ctypes.Structure):
    _fields_ = [
        ("lpServiceName", ctypes.c_void_p),
        ("lpDisplayName", ctypes.c_void_p),
        ("ServiceStatus", SERVICE_STATUS),
    ]
#[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,
}

#[repr(C)]
pub struct ENUM_SERVICE_STATUSW {
    pub lpServiceName: *mut core::ffi::c_void,
    pub lpDisplayName: *mut core::ffi::c_void,
    pub ServiceStatus: SERVICE_STATUS,
}
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 ENUM_SERVICE_STATUSW struct {
	lpServiceName uintptr
	lpDisplayName uintptr
	ServiceStatus SERVICE_STATUS
}
type
  SERVICE_STATUS = record
    dwServiceType: DWORD;
    dwCurrentState: DWORD;
    dwControlsAccepted: DWORD;
    dwWin32ExitCode: DWORD;
    dwServiceSpecificExitCode: DWORD;
    dwCheckPoint: DWORD;
    dwWaitHint: DWORD;
  end;

  ENUM_SERVICE_STATUSW = record
    lpServiceName: Pointer;
    lpDisplayName: Pointer;
    ServiceStatus: SERVICE_STATUS;
  end;
const SERVICE_STATUS = extern struct {
    dwServiceType: u32,
    dwCurrentState: u32,
    dwControlsAccepted: u32,
    dwWin32ExitCode: u32,
    dwServiceSpecificExitCode: u32,
    dwCheckPoint: u32,
    dwWaitHint: u32,
};

const ENUM_SERVICE_STATUSW = extern struct {
    lpServiceName: ?*anyopaque,
    lpDisplayName: ?*anyopaque,
    ServiceStatus: SERVICE_STATUS,
};
type
  SERVICE_STATUS {.bycopy.} = object
    dwServiceType: uint32
    dwCurrentState: uint32
    dwControlsAccepted: uint32
    dwWin32ExitCode: uint32
    dwServiceSpecificExitCode: uint32
    dwCheckPoint: uint32
    dwWaitHint: uint32

  ENUM_SERVICE_STATUSW {.bycopy.} = object
    lpServiceName: pointer
    lpDisplayName: pointer
    ServiceStatus: SERVICE_STATUS
struct SERVICE_STATUS
{
    uint dwServiceType;
    uint dwCurrentState;
    uint dwControlsAccepted;
    uint dwWin32ExitCode;
    uint dwServiceSpecificExitCode;
    uint dwCheckPoint;
    uint dwWaitHint;
}

struct ENUM_SERVICE_STATUSW
{
    void* lpServiceName;
    void* lpDisplayName;
    SERVICE_STATUS ServiceStatus;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; ENUM_SERVICE_STATUSW サイズ: 36 バイト(x86)
dim st, 9    ; 4byte整数×9(構造体サイズ 36 / 4 切り上げ)
; lpServiceName : LPWSTR (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; lpDisplayName : LPWSTR (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; ServiceStatus : SERVICE_STATUS (+8, 28byte)  varptr(st)+8 を基点に操作(28byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; ENUM_SERVICE_STATUSW サイズ: 48 バイト(x64)
dim st, 12    ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; lpServiceName : LPWSTR (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; lpDisplayName : LPWSTR (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; ServiceStatus : SERVICE_STATUS (+16, 28byte)  varptr(st)+16 を基点に操作(28byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#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

#defstruct global ENUM_SERVICE_STATUSW
    #field intptr lpServiceName
    #field intptr lpDisplayName
    #field SERVICE_STATUS ServiceStatus
#endstruct

stdim st, ENUM_SERVICE_STATUSW        ; NSTRUCT 変数を確保