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

TRIGGER_TYPE_UNION

共用体
サイズx64: 8 バイト / x86: 8 バイト

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

フィールド

フィールドサイズx64x86説明
DailyDAILY2+0+0毎日実行トリガー用の設定。DAILY構造体。
WeeklyWEEKLY4+0+0毎週実行トリガー用の設定。WEEKLY構造体。
MonthlyDateMONTHLYDATE8+0+0毎月の特定日実行トリガー用の設定。MONTHLYDATE構造体。
MonthlyDOWMONTHLYDOW6+0+0毎月の特定曜日実行トリガー用の設定。MONTHLYDOW構造体。

各言語での定義

#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;
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;
}
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
import 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),
    ]
#[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,
}
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
  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;
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,
};
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
struct 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;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; TRIGGER_TYPE_UNION サイズ: 8 バイト(x64)
dim st, 2    ; 4byte整数×2(構造体サイズ 8 / 4 切り上げ)
; Daily : DAILY (+0, 2byte)  varptr(st)+0 を基点に操作(2byte:入れ子/配列)
; Weekly : WEEKLY (+0, 4byte)  varptr(st)+0 を基点に操作(4byte:入れ子/配列)
; MonthlyDate : MONTHLYDATE (+0, 8byte)  varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; MonthlyDOW : MONTHLYDOW (+0, 6byte)  varptr(st)+0 を基点に操作(6byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global DAILY
    #field short DaysInterval
#endstruct

#defstruct global WEEKLY
    #field short WeeksInterval
    #field short rgfDaysOfTheWeek
#endstruct

#defstruct global MONTHLYDATE
    #field int rgfDays
    #field short rgfMonths
#endstruct

#defstruct global MONTHLYDOW
    #field short wWhichWeek
    #field short rgfDaysOfTheWeek
    #field short rgfMonths
#endstruct

#defstruct global TRIGGER_TYPE_UNION
    #field DAILY Daily
    #field WEEKLY Weekly
    #field MONTHLYDATE MonthlyDate
    #field MONTHLYDOW MonthlyDOW
#endstruct

stdim st, TRIGGER_TYPE_UNION        ; NSTRUCT 変数を確保