Win32 API 日本語リファレンス
ホームNetworkManagement.NetManagement › STD_ALERT

STD_ALERT

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

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

フィールド

フィールドサイズx64x86説明
alrt_timestampDWORD4+0+0アラート発生時刻を1970/1/1からの経過秒数(time_t)で示す。
alrt_eventnameWCHAR34+4+4アラートを発生させたイベントの名前を示す固定長WCHAR配列。
alrt_servicenameWCHAR162+38+38アラートを発生させたサービスの名前を示す固定長WCHAR配列。

各言語での定義

#include <windows.h>

// STD_ALERT  (x64 200 / x86 200 バイト)
typedef struct STD_ALERT {
    DWORD alrt_timestamp;
    WCHAR alrt_eventname[17];
    WCHAR alrt_servicename[81];
} STD_ALERT;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct STD_ALERT
{
    public uint alrt_timestamp;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 17)] public string alrt_eventname;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 81)] public string alrt_servicename;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure STD_ALERT
    Public alrt_timestamp As UInteger
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=17)> Public alrt_eventname As String
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=81)> Public alrt_servicename As String
End Structure
import ctypes
from ctypes import wintypes

class STD_ALERT(ctypes.Structure):
    _fields_ = [
        ("alrt_timestamp", wintypes.DWORD),
        ("alrt_eventname", ctypes.c_wchar * 17),
        ("alrt_servicename", ctypes.c_wchar * 81),
    ]
#[repr(C)]
pub struct STD_ALERT {
    pub alrt_timestamp: u32,
    pub alrt_eventname: [u16; 17],
    pub alrt_servicename: [u16; 81],
}
import "golang.org/x/sys/windows"

type STD_ALERT struct {
	alrt_timestamp uint32
	alrt_eventname [17]uint16
	alrt_servicename [81]uint16
}
type
  STD_ALERT = record
    alrt_timestamp: DWORD;
    alrt_eventname: array[0..16] of WideChar;
    alrt_servicename: array[0..80] of WideChar;
  end;
const STD_ALERT = extern struct {
    alrt_timestamp: u32,
    alrt_eventname: [17]u16,
    alrt_servicename: [81]u16,
};
type
  STD_ALERT {.bycopy.} = object
    alrt_timestamp: uint32
    alrt_eventname: array[17, uint16]
    alrt_servicename: array[81, uint16]
struct STD_ALERT
{
    uint alrt_timestamp;
    wchar[17] alrt_eventname;
    wchar[81] alrt_servicename;
}

HSP用 定義

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

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

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