ホーム › System.Services › SERVICE_NOTIFY_2W
SERVICE_NOTIFY_2W
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| dwVersion | DWORD | 4 | +0 | +0 | この構造体のバージョン。SERVICE_NOTIFY_STATUS_CHANGE を指定する。 |
| pfnNotifyCallback | PFN_SC_NOTIFY_CALLBACK | 8/4 | +8 | +4 | 状態変化時に呼び出される通知コールバック関数へのポインター。 |
| pContext | void* | 8/4 | +16 | +8 | コールバックへ渡すユーザー定義のコンテキストポインター。NULL 可。 |
| dwNotificationStatus | DWORD | 4 | +24 | +12 | 通知処理の結果コード。成功時は ERROR_SUCCESS。 |
| ServiceStatus | SERVICE_STATUS_PROCESS | 36 | +28 | +16 | 通知時点のサービス状態を含む SERVICE_STATUS_PROCESS。 |
| dwNotificationTriggered | DWORD | 4 | +64 | +52 | 発生した通知の種類を示すフラグのビット集合。 |
| pszServiceNames | LPWSTR | 8/4 | +72 | +56 | 作成/削除されたサービス名の複数文字列(ワイド)。二重 NULL 終端。 |
各言語での定義
#include <windows.h>
// SERVICE_STATUS_PROCESS (x64 36 / x86 36 バイト)
typedef struct SERVICE_STATUS_PROCESS {
ENUM_SERVICE_TYPE dwServiceType;
SERVICE_STATUS_CURRENT_STATE dwCurrentState;
DWORD dwControlsAccepted;
DWORD dwWin32ExitCode;
DWORD dwServiceSpecificExitCode;
DWORD dwCheckPoint;
DWORD dwWaitHint;
DWORD dwProcessId;
SERVICE_RUNS_IN_PROCESS dwServiceFlags;
} SERVICE_STATUS_PROCESS;
// SERVICE_NOTIFY_2W (x64 80 / x86 60 バイト)
typedef struct SERVICE_NOTIFY_2W {
DWORD dwVersion;
PFN_SC_NOTIFY_CALLBACK pfnNotifyCallback;
void* pContext;
DWORD dwNotificationStatus;
SERVICE_STATUS_PROCESS ServiceStatus;
DWORD dwNotificationTriggered;
LPWSTR pszServiceNames;
} SERVICE_NOTIFY_2W;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SERVICE_STATUS_PROCESS
{
public uint dwServiceType;
public uint dwCurrentState;
public uint dwControlsAccepted;
public uint dwWin32ExitCode;
public uint dwServiceSpecificExitCode;
public uint dwCheckPoint;
public uint dwWaitHint;
public uint dwProcessId;
public uint dwServiceFlags;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SERVICE_NOTIFY_2W
{
public uint dwVersion;
public IntPtr pfnNotifyCallback;
public IntPtr pContext;
public uint dwNotificationStatus;
public SERVICE_STATUS_PROCESS ServiceStatus;
public uint dwNotificationTriggered;
public IntPtr pszServiceNames;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SERVICE_STATUS_PROCESS
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
Public dwProcessId As UInteger
Public dwServiceFlags As UInteger
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SERVICE_NOTIFY_2W
Public dwVersion As UInteger
Public pfnNotifyCallback As IntPtr
Public pContext As IntPtr
Public dwNotificationStatus As UInteger
Public ServiceStatus As SERVICE_STATUS_PROCESS
Public dwNotificationTriggered As UInteger
Public pszServiceNames As IntPtr
End Structureimport ctypes
from ctypes import wintypes
class SERVICE_STATUS_PROCESS(ctypes.Structure):
_fields_ = [
("dwServiceType", wintypes.DWORD),
("dwCurrentState", wintypes.DWORD),
("dwControlsAccepted", wintypes.DWORD),
("dwWin32ExitCode", wintypes.DWORD),
("dwServiceSpecificExitCode", wintypes.DWORD),
("dwCheckPoint", wintypes.DWORD),
("dwWaitHint", wintypes.DWORD),
("dwProcessId", wintypes.DWORD),
("dwServiceFlags", wintypes.DWORD),
]
class SERVICE_NOTIFY_2W(ctypes.Structure):
_fields_ = [
("dwVersion", wintypes.DWORD),
("pfnNotifyCallback", ctypes.c_void_p),
("pContext", ctypes.c_void_p),
("dwNotificationStatus", wintypes.DWORD),
("ServiceStatus", SERVICE_STATUS_PROCESS),
("dwNotificationTriggered", wintypes.DWORD),
("pszServiceNames", ctypes.c_void_p),
]#[repr(C)]
pub struct SERVICE_STATUS_PROCESS {
pub dwServiceType: u32,
pub dwCurrentState: u32,
pub dwControlsAccepted: u32,
pub dwWin32ExitCode: u32,
pub dwServiceSpecificExitCode: u32,
pub dwCheckPoint: u32,
pub dwWaitHint: u32,
pub dwProcessId: u32,
pub dwServiceFlags: u32,
}
#[repr(C)]
pub struct SERVICE_NOTIFY_2W {
pub dwVersion: u32,
pub pfnNotifyCallback: *mut core::ffi::c_void,
pub pContext: *mut core::ffi::c_void,
pub dwNotificationStatus: u32,
pub ServiceStatus: SERVICE_STATUS_PROCESS,
pub dwNotificationTriggered: u32,
pub pszServiceNames: *mut core::ffi::c_void,
}import "golang.org/x/sys/windows"
type SERVICE_STATUS_PROCESS struct {
dwServiceType uint32
dwCurrentState uint32
dwControlsAccepted uint32
dwWin32ExitCode uint32
dwServiceSpecificExitCode uint32
dwCheckPoint uint32
dwWaitHint uint32
dwProcessId uint32
dwServiceFlags uint32
}
type SERVICE_NOTIFY_2W struct {
dwVersion uint32
pfnNotifyCallback uintptr
pContext uintptr
dwNotificationStatus uint32
ServiceStatus SERVICE_STATUS_PROCESS
dwNotificationTriggered uint32
pszServiceNames uintptr
}type
SERVICE_STATUS_PROCESS = record
dwServiceType: DWORD;
dwCurrentState: DWORD;
dwControlsAccepted: DWORD;
dwWin32ExitCode: DWORD;
dwServiceSpecificExitCode: DWORD;
dwCheckPoint: DWORD;
dwWaitHint: DWORD;
dwProcessId: DWORD;
dwServiceFlags: DWORD;
end;
SERVICE_NOTIFY_2W = record
dwVersion: DWORD;
pfnNotifyCallback: Pointer;
pContext: Pointer;
dwNotificationStatus: DWORD;
ServiceStatus: SERVICE_STATUS_PROCESS;
dwNotificationTriggered: DWORD;
pszServiceNames: Pointer;
end;const SERVICE_STATUS_PROCESS = extern struct {
dwServiceType: u32,
dwCurrentState: u32,
dwControlsAccepted: u32,
dwWin32ExitCode: u32,
dwServiceSpecificExitCode: u32,
dwCheckPoint: u32,
dwWaitHint: u32,
dwProcessId: u32,
dwServiceFlags: u32,
};
const SERVICE_NOTIFY_2W = extern struct {
dwVersion: u32,
pfnNotifyCallback: ?*anyopaque,
pContext: ?*anyopaque,
dwNotificationStatus: u32,
ServiceStatus: SERVICE_STATUS_PROCESS,
dwNotificationTriggered: u32,
pszServiceNames: ?*anyopaque,
};type
SERVICE_STATUS_PROCESS {.bycopy.} = object
dwServiceType: uint32
dwCurrentState: uint32
dwControlsAccepted: uint32
dwWin32ExitCode: uint32
dwServiceSpecificExitCode: uint32
dwCheckPoint: uint32
dwWaitHint: uint32
dwProcessId: uint32
dwServiceFlags: uint32
SERVICE_NOTIFY_2W {.bycopy.} = object
dwVersion: uint32
pfnNotifyCallback: pointer
pContext: pointer
dwNotificationStatus: uint32
ServiceStatus: SERVICE_STATUS_PROCESS
dwNotificationTriggered: uint32
pszServiceNames: pointerstruct SERVICE_STATUS_PROCESS
{
uint dwServiceType;
uint dwCurrentState;
uint dwControlsAccepted;
uint dwWin32ExitCode;
uint dwServiceSpecificExitCode;
uint dwCheckPoint;
uint dwWaitHint;
uint dwProcessId;
uint dwServiceFlags;
}
struct SERVICE_NOTIFY_2W
{
uint dwVersion;
void* pfnNotifyCallback;
void* pContext;
uint dwNotificationStatus;
SERVICE_STATUS_PROCESS ServiceStatus;
uint dwNotificationTriggered;
void* pszServiceNames;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; SERVICE_NOTIFY_2W サイズ: 60 バイト(x86)
dim st, 15 ; 4byte整数×15(構造体サイズ 60 / 4 切り上げ)
; dwVersion : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; pfnNotifyCallback : PFN_SC_NOTIFY_CALLBACK (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; pContext : void* (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; dwNotificationStatus : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; ServiceStatus : SERVICE_STATUS_PROCESS (+16, 36byte) varptr(st)+16 を基点に操作(36byte:入れ子/配列)
; dwNotificationTriggered : DWORD (+52, 4byte) st.13 = 値 / 値 = st.13 (lpoke/lpeek も可)
; pszServiceNames : LPWSTR (+56, 4byte) st.14 = 値 / 値 = st.14 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SERVICE_NOTIFY_2W サイズ: 80 バイト(x64)
dim st, 20 ; 4byte整数×20(構造体サイズ 80 / 4 切り上げ)
; dwVersion : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; pfnNotifyCallback : PFN_SC_NOTIFY_CALLBACK (+8, 8byte) qpoke st,8,値 / qpeek(st,8) ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; pContext : void* (+16, 8byte) qpoke st,16,値 / qpeek(st,16) ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; dwNotificationStatus : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; ServiceStatus : SERVICE_STATUS_PROCESS (+28, 36byte) varptr(st)+28 を基点に操作(36byte:入れ子/配列)
; dwNotificationTriggered : DWORD (+64, 4byte) st.16 = 値 / 値 = st.16 (lpoke/lpeek も可)
; pszServiceNames : LPWSTR (+72, 8byte) qpoke st,72,値 / qpeek(st,72) ※IronHSPのみ。3.7/3.8は lpoke st,72,下位 : lpoke st,76,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global SERVICE_STATUS_PROCESS
#field int dwServiceType
#field int dwCurrentState
#field int dwControlsAccepted
#field int dwWin32ExitCode
#field int dwServiceSpecificExitCode
#field int dwCheckPoint
#field int dwWaitHint
#field int dwProcessId
#field int dwServiceFlags
#endstruct
#defstruct global SERVICE_NOTIFY_2W
#field int dwVersion
#field intptr pfnNotifyCallback
#field intptr pContext
#field int dwNotificationStatus
#field SERVICE_STATUS_PROCESS ServiceStatus
#field int dwNotificationTriggered
#field intptr pszServiceNames
#endstruct
stdim st, SERVICE_NOTIFY_2W ; NSTRUCT 変数を確保
st->dwVersion = 100
mes "dwVersion=" + st->dwVersion