ホーム › System.TaskScheduler › TASK_TRIGGER
TASK_TRIGGER
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| cbTriggerSize | WORD | 2 | +0 | +0 | この構造体のサイズ(バイト)。互換性確認に使用する。 |
| Reserved1 | WORD | 2 | +2 | +2 | 予約フィールド。0を設定する。 |
| wBeginYear | WORD | 2 | +4 | +4 | トリガーの有効開始年。 |
| wBeginMonth | WORD | 2 | +6 | +6 | トリガーの有効開始月(1〜12)。 |
| wBeginDay | WORD | 2 | +8 | +8 | トリガーの有効開始日(1〜31)。 |
| wEndYear | WORD | 2 | +10 | +10 | トリガーの有効終了年。 |
| wEndMonth | WORD | 2 | +12 | +12 | トリガーの有効終了月(1〜12)。 |
| wEndDay | WORD | 2 | +14 | +14 | トリガーの有効終了日(1〜31)。 |
| wStartHour | WORD | 2 | +16 | +16 | タスク開始時刻の時(0〜23)。 |
| wStartMinute | WORD | 2 | +18 | +18 | タスク開始時刻の分(0〜59)。 |
| MinutesDuration | DWORD | 4 | +20 | +20 | トリガー有効期間の長さ(分)。この間に繰り返し実行される。 |
| MinutesInterval | DWORD | 4 | +24 | +24 | 繰り返し実行の間隔(分)。0で繰り返しなし。 |
| rgFlags | DWORD | 4 | +28 | +28 | トリガー動作を制御するフラグのビットマスク(TASK_TRIGGER_FLAGS)。 |
| TriggerType | TASK_TRIGGER_TYPE | 4 | +32 | +32 | トリガーの種別を示す列挙値(TASK_TRIGGER_TYPE)。 |
| Type | TRIGGER_TYPE_UNION | 8 | +36 | +36 | トリガー種別に応じた詳細設定を保持する共用体。 |
| Reserved2 | WORD | 2 | +44 | +44 | 予約フィールド。0を設定する。 |
| wRandomMinutesInterval | WORD | 2 | +46 | +46 | 実行開始をずらすランダム遅延の最大分数。0で遅延なし。 |
各言語での定義
#include <windows.h>
// DAILY (x64 2 / x86 2 バイト)
typedef struct DAILY {
WORD DaysInterval;
} DAILY;
// WEEKLY (x64 4 / x86 4 バイト)
typedef struct WEEKLY {
WORD WeeksInterval;
WORD rgfDaysOfTheWeek;
} WEEKLY;
// MONTHLYDATE (x64 8 / x86 8 バイト)
typedef struct MONTHLYDATE {
DWORD rgfDays;
WORD rgfMonths;
} MONTHLYDATE;
// MONTHLYDOW (x64 6 / x86 6 バイト)
typedef struct MONTHLYDOW {
WORD wWhichWeek;
WORD rgfDaysOfTheWeek;
WORD rgfMonths;
} MONTHLYDOW;
// TRIGGER_TYPE_UNION (x64 8 / x86 8 バイト)
typedef struct TRIGGER_TYPE_UNION {
DAILY Daily;
WEEKLY Weekly;
MONTHLYDATE MonthlyDate;
MONTHLYDOW MonthlyDOW;
} TRIGGER_TYPE_UNION;
// TASK_TRIGGER (x64 48 / x86 48 バイト)
typedef struct TASK_TRIGGER {
WORD cbTriggerSize;
WORD Reserved1;
WORD wBeginYear;
WORD wBeginMonth;
WORD wBeginDay;
WORD wEndYear;
WORD wEndMonth;
WORD wEndDay;
WORD wStartHour;
WORD wStartMinute;
DWORD MinutesDuration;
DWORD MinutesInterval;
DWORD rgFlags;
TASK_TRIGGER_TYPE TriggerType;
TRIGGER_TYPE_UNION Type;
WORD Reserved2;
WORD wRandomMinutesInterval;
} TASK_TRIGGER;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DAILY
{
public ushort DaysInterval;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WEEKLY
{
public ushort WeeksInterval;
public ushort rgfDaysOfTheWeek;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MONTHLYDATE
{
public uint rgfDays;
public ushort rgfMonths;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MONTHLYDOW
{
public ushort wWhichWeek;
public ushort rgfDaysOfTheWeek;
public ushort rgfMonths;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct TRIGGER_TYPE_UNION
{
public DAILY Daily;
public WEEKLY Weekly;
public MONTHLYDATE MonthlyDate;
public MONTHLYDOW MonthlyDOW;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct TASK_TRIGGER
{
public ushort cbTriggerSize;
public ushort Reserved1;
public ushort wBeginYear;
public ushort wBeginMonth;
public ushort wBeginDay;
public ushort wEndYear;
public ushort wEndMonth;
public ushort wEndDay;
public ushort wStartHour;
public ushort wStartMinute;
public uint MinutesDuration;
public uint MinutesInterval;
public uint rgFlags;
public int TriggerType;
public TRIGGER_TYPE_UNION Type;
public ushort Reserved2;
public ushort wRandomMinutesInterval;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DAILY
Public DaysInterval As UShort
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WEEKLY
Public WeeksInterval As UShort
Public rgfDaysOfTheWeek As UShort
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure MONTHLYDATE
Public rgfDays As UInteger
Public rgfMonths As UShort
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure MONTHLYDOW
Public wWhichWeek As UShort
Public rgfDaysOfTheWeek As UShort
Public rgfMonths As UShort
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure TRIGGER_TYPE_UNION
Public Daily As DAILY
Public Weekly As WEEKLY
Public MonthlyDate As MONTHLYDATE
Public MonthlyDOW As MONTHLYDOW
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure TASK_TRIGGER
Public cbTriggerSize As UShort
Public Reserved1 As UShort
Public wBeginYear As UShort
Public wBeginMonth As UShort
Public wBeginDay As UShort
Public wEndYear As UShort
Public wEndMonth As UShort
Public wEndDay As UShort
Public wStartHour As UShort
Public wStartMinute As UShort
Public MinutesDuration As UInteger
Public MinutesInterval As UInteger
Public rgFlags As UInteger
Public TriggerType As Integer
Public Type As TRIGGER_TYPE_UNION
Public Reserved2 As UShort
Public wRandomMinutesInterval As UShort
End Structureimport ctypes
from ctypes import wintypes
class DAILY(ctypes.Structure):
_fields_ = [
("DaysInterval", ctypes.c_ushort),
]
class WEEKLY(ctypes.Structure):
_fields_ = [
("WeeksInterval", ctypes.c_ushort),
("rgfDaysOfTheWeek", ctypes.c_ushort),
]
class MONTHLYDATE(ctypes.Structure):
_fields_ = [
("rgfDays", wintypes.DWORD),
("rgfMonths", ctypes.c_ushort),
]
class MONTHLYDOW(ctypes.Structure):
_fields_ = [
("wWhichWeek", ctypes.c_ushort),
("rgfDaysOfTheWeek", ctypes.c_ushort),
("rgfMonths", ctypes.c_ushort),
]
class TRIGGER_TYPE_UNION(ctypes.Structure):
_fields_ = [
("Daily", DAILY),
("Weekly", WEEKLY),
("MonthlyDate", MONTHLYDATE),
("MonthlyDOW", MONTHLYDOW),
]
class TASK_TRIGGER(ctypes.Structure):
_fields_ = [
("cbTriggerSize", ctypes.c_ushort),
("Reserved1", ctypes.c_ushort),
("wBeginYear", ctypes.c_ushort),
("wBeginMonth", ctypes.c_ushort),
("wBeginDay", ctypes.c_ushort),
("wEndYear", ctypes.c_ushort),
("wEndMonth", ctypes.c_ushort),
("wEndDay", ctypes.c_ushort),
("wStartHour", ctypes.c_ushort),
("wStartMinute", ctypes.c_ushort),
("MinutesDuration", wintypes.DWORD),
("MinutesInterval", wintypes.DWORD),
("rgFlags", wintypes.DWORD),
("TriggerType", ctypes.c_int),
("Type", TRIGGER_TYPE_UNION),
("Reserved2", ctypes.c_ushort),
("wRandomMinutesInterval", ctypes.c_ushort),
]#[repr(C)]
pub struct DAILY {
pub DaysInterval: u16,
}
#[repr(C)]
pub struct WEEKLY {
pub WeeksInterval: u16,
pub rgfDaysOfTheWeek: u16,
}
#[repr(C)]
pub struct MONTHLYDATE {
pub rgfDays: u32,
pub rgfMonths: u16,
}
#[repr(C)]
pub struct MONTHLYDOW {
pub wWhichWeek: u16,
pub rgfDaysOfTheWeek: u16,
pub rgfMonths: u16,
}
#[repr(C)]
pub struct TRIGGER_TYPE_UNION {
pub Daily: DAILY,
pub Weekly: WEEKLY,
pub MonthlyDate: MONTHLYDATE,
pub MonthlyDOW: MONTHLYDOW,
}
#[repr(C)]
pub struct TASK_TRIGGER {
pub cbTriggerSize: u16,
pub Reserved1: u16,
pub wBeginYear: u16,
pub wBeginMonth: u16,
pub wBeginDay: u16,
pub wEndYear: u16,
pub wEndMonth: u16,
pub wEndDay: u16,
pub wStartHour: u16,
pub wStartMinute: u16,
pub MinutesDuration: u32,
pub MinutesInterval: u32,
pub rgFlags: u32,
pub TriggerType: i32,
pub Type: TRIGGER_TYPE_UNION,
pub Reserved2: u16,
pub wRandomMinutesInterval: u16,
}import "golang.org/x/sys/windows"
type DAILY struct {
DaysInterval uint16
}
type WEEKLY struct {
WeeksInterval uint16
rgfDaysOfTheWeek uint16
}
type MONTHLYDATE struct {
rgfDays uint32
rgfMonths uint16
}
type MONTHLYDOW struct {
wWhichWeek uint16
rgfDaysOfTheWeek uint16
rgfMonths uint16
}
type TRIGGER_TYPE_UNION struct {
Daily DAILY
Weekly WEEKLY
MonthlyDate MONTHLYDATE
MonthlyDOW MONTHLYDOW
}
type TASK_TRIGGER struct {
cbTriggerSize uint16
Reserved1 uint16
wBeginYear uint16
wBeginMonth uint16
wBeginDay uint16
wEndYear uint16
wEndMonth uint16
wEndDay uint16
wStartHour uint16
wStartMinute uint16
MinutesDuration uint32
MinutesInterval uint32
rgFlags uint32
TriggerType int32
Type TRIGGER_TYPE_UNION
Reserved2 uint16
wRandomMinutesInterval uint16
}type
DAILY = record
DaysInterval: Word;
end;
WEEKLY = record
WeeksInterval: Word;
rgfDaysOfTheWeek: Word;
end;
MONTHLYDATE = record
rgfDays: DWORD;
rgfMonths: Word;
end;
MONTHLYDOW = record
wWhichWeek: Word;
rgfDaysOfTheWeek: Word;
rgfMonths: Word;
end;
TRIGGER_TYPE_UNION = record
Daily: DAILY;
Weekly: WEEKLY;
MonthlyDate: MONTHLYDATE;
MonthlyDOW: MONTHLYDOW;
end;
TASK_TRIGGER = record
cbTriggerSize: Word;
Reserved1: Word;
wBeginYear: Word;
wBeginMonth: Word;
wBeginDay: Word;
wEndYear: Word;
wEndMonth: Word;
wEndDay: Word;
wStartHour: Word;
wStartMinute: Word;
MinutesDuration: DWORD;
MinutesInterval: DWORD;
rgFlags: DWORD;
TriggerType: Integer;
Type: TRIGGER_TYPE_UNION;
Reserved2: Word;
wRandomMinutesInterval: Word;
end;const DAILY = extern struct {
DaysInterval: u16,
};
const WEEKLY = extern struct {
WeeksInterval: u16,
rgfDaysOfTheWeek: u16,
};
const MONTHLYDATE = extern struct {
rgfDays: u32,
rgfMonths: u16,
};
const MONTHLYDOW = extern struct {
wWhichWeek: u16,
rgfDaysOfTheWeek: u16,
rgfMonths: u16,
};
const TRIGGER_TYPE_UNION = extern struct {
Daily: DAILY,
Weekly: WEEKLY,
MonthlyDate: MONTHLYDATE,
MonthlyDOW: MONTHLYDOW,
};
const TASK_TRIGGER = extern struct {
cbTriggerSize: u16,
Reserved1: u16,
wBeginYear: u16,
wBeginMonth: u16,
wBeginDay: u16,
wEndYear: u16,
wEndMonth: u16,
wEndDay: u16,
wStartHour: u16,
wStartMinute: u16,
MinutesDuration: u32,
MinutesInterval: u32,
rgFlags: u32,
TriggerType: i32,
Type: TRIGGER_TYPE_UNION,
Reserved2: u16,
wRandomMinutesInterval: u16,
};type
DAILY {.bycopy.} = object
DaysInterval: uint16
WEEKLY {.bycopy.} = object
WeeksInterval: uint16
rgfDaysOfTheWeek: uint16
MONTHLYDATE {.bycopy.} = object
rgfDays: uint32
rgfMonths: uint16
MONTHLYDOW {.bycopy.} = object
wWhichWeek: uint16
rgfDaysOfTheWeek: uint16
rgfMonths: uint16
TRIGGER_TYPE_UNION {.bycopy.} = object
Daily: DAILY
Weekly: WEEKLY
MonthlyDate: MONTHLYDATE
MonthlyDOW: MONTHLYDOW
TASK_TRIGGER {.bycopy.} = object
cbTriggerSize: uint16
Reserved1: uint16
wBeginYear: uint16
wBeginMonth: uint16
wBeginDay: uint16
wEndYear: uint16
wEndMonth: uint16
wEndDay: uint16
wStartHour: uint16
wStartMinute: uint16
MinutesDuration: uint32
MinutesInterval: uint32
rgFlags: uint32
TriggerType: int32
Type: TRIGGER_TYPE_UNION
Reserved2: uint16
wRandomMinutesInterval: uint16struct DAILY
{
ushort DaysInterval;
}
struct WEEKLY
{
ushort WeeksInterval;
ushort rgfDaysOfTheWeek;
}
struct MONTHLYDATE
{
uint rgfDays;
ushort rgfMonths;
}
struct MONTHLYDOW
{
ushort wWhichWeek;
ushort rgfDaysOfTheWeek;
ushort rgfMonths;
}
struct TRIGGER_TYPE_UNION
{
DAILY Daily;
WEEKLY Weekly;
MONTHLYDATE MonthlyDate;
MONTHLYDOW MonthlyDOW;
}
struct TASK_TRIGGER
{
ushort cbTriggerSize;
ushort Reserved1;
ushort wBeginYear;
ushort wBeginMonth;
ushort wBeginDay;
ushort wEndYear;
ushort wEndMonth;
ushort wEndDay;
ushort wStartHour;
ushort wStartMinute;
uint MinutesDuration;
uint MinutesInterval;
uint rgFlags;
int TriggerType;
TRIGGER_TYPE_UNION Type;
ushort Reserved2;
ushort wRandomMinutesInterval;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; TASK_TRIGGER サイズ: 48 バイト(x64)
dim st, 12 ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; cbTriggerSize : WORD (+0, 2byte) wpoke st,0,値 / 値 = wpeek(st,0)
; Reserved1 : WORD (+2, 2byte) wpoke st,2,値 / 値 = wpeek(st,2)
; wBeginYear : WORD (+4, 2byte) wpoke st,4,値 / 値 = wpeek(st,4)
; wBeginMonth : WORD (+6, 2byte) wpoke st,6,値 / 値 = wpeek(st,6)
; wBeginDay : WORD (+8, 2byte) wpoke st,8,値 / 値 = wpeek(st,8)
; wEndYear : WORD (+10, 2byte) wpoke st,10,値 / 値 = wpeek(st,10)
; wEndMonth : WORD (+12, 2byte) wpoke st,12,値 / 値 = wpeek(st,12)
; wEndDay : WORD (+14, 2byte) wpoke st,14,値 / 値 = wpeek(st,14)
; wStartHour : WORD (+16, 2byte) wpoke st,16,値 / 値 = wpeek(st,16)
; wStartMinute : WORD (+18, 2byte) wpoke st,18,値 / 値 = wpeek(st,18)
; MinutesDuration : DWORD (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; MinutesInterval : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; rgFlags : DWORD (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; TriggerType : TASK_TRIGGER_TYPE (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; Type : TRIGGER_TYPE_UNION (+36, 8byte) varptr(st)+36 を基点に操作(8byte:入れ子/配列)
; Reserved2 : WORD (+44, 2byte) wpoke st,44,値 / 値 = wpeek(st,44)
; wRandomMinutesInterval : WORD (+46, 2byte) wpoke st,46,値 / 値 = wpeek(st,46)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global TASK_TRIGGER
#field short cbTriggerSize
#field short Reserved1
#field short wBeginYear
#field short wBeginMonth
#field short wBeginDay
#field short wEndYear
#field short wEndMonth
#field short wEndDay
#field short wStartHour
#field short wStartMinute
#field int MinutesDuration
#field int MinutesInterval
#field int rgFlags
#field int TriggerType
#field byte Type 8
#field short Reserved2
#field short wRandomMinutesInterval
#endstruct
stdim st, TASK_TRIGGER ; NSTRUCT 変数を確保
st->cbTriggerSize = 100
mes "cbTriggerSize=" + st->cbTriggerSize
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。