Win32 API 日本語リファレンス
ホームMedia.Multimedia › TIMEREVENT

TIMEREVENT

構造体
サイズx64: 20 バイト / x86: 16 バイトパッキング1

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

フィールド

フィールドサイズx64x86説明
wDelayWORD2+0+0タイマイベントの遅延時間をミリ秒で指定する。
wResolutionWORD2+2+2タイマの分解能をミリ秒で指定する。0で最高精度。
lpFunctionLPTIMECALLBACK8/4+4+4タイマ満了時に呼ばれるコールバック関数へのポインタ。
dwUserDWORD4+12+8コールバックへ渡されるユーザ定義データ。
wFlagsWORD2+16+12タイマの種類フラグ。TIME_ONESHOT/TIME_PERIODIC等を指定する。
wReserved1WORD2+18+14予約領域。使用しない。

各言語での定義

#include <windows.h>

// TIMEREVENT  (x64 20 / x86 16 バイト)
#pragma pack(push, 1)
typedef struct TIMEREVENT {
    WORD wDelay;
    WORD wResolution;
    LPTIMECALLBACK lpFunction;
    DWORD dwUser;
    WORD wFlags;
    WORD wReserved1;
} TIMEREVENT;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct TIMEREVENT
{
    public ushort wDelay;
    public ushort wResolution;
    public IntPtr lpFunction;
    public uint dwUser;
    public ushort wFlags;
    public ushort wReserved1;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure TIMEREVENT
    Public wDelay As UShort
    Public wResolution As UShort
    Public lpFunction As IntPtr
    Public dwUser As UInteger
    Public wFlags As UShort
    Public wReserved1 As UShort
End Structure
import ctypes
from ctypes import wintypes

class TIMEREVENT(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("wDelay", ctypes.c_ushort),
        ("wResolution", ctypes.c_ushort),
        ("lpFunction", ctypes.c_void_p),
        ("dwUser", wintypes.DWORD),
        ("wFlags", ctypes.c_ushort),
        ("wReserved1", ctypes.c_ushort),
    ]
#[repr(C, packed(1))]
pub struct TIMEREVENT {
    pub wDelay: u16,
    pub wResolution: u16,
    pub lpFunction: *mut core::ffi::c_void,
    pub dwUser: u32,
    pub wFlags: u16,
    pub wReserved1: u16,
}
import "golang.org/x/sys/windows"

type TIMEREVENT struct {
	wDelay uint16
	wResolution uint16
	lpFunction uintptr
	dwUser uint32
	wFlags uint16
	wReserved1 uint16
}
type
  TIMEREVENT = packed record
    wDelay: Word;
    wResolution: Word;
    lpFunction: Pointer;
    dwUser: DWORD;
    wFlags: Word;
    wReserved1: Word;
  end;
const TIMEREVENT = extern struct {
    wDelay: u16,
    wResolution: u16,
    lpFunction: ?*anyopaque,
    dwUser: u32,
    wFlags: u16,
    wReserved1: u16,
};
type
  TIMEREVENT {.packed.} = object
    wDelay: uint16
    wResolution: uint16
    lpFunction: pointer
    dwUser: uint32
    wFlags: uint16
    wReserved1: uint16
align(1)
struct TIMEREVENT
{
    ushort wDelay;
    ushort wResolution;
    void* lpFunction;
    uint dwUser;
    ushort wFlags;
    ushort wReserved1;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; TIMEREVENT サイズ: 16 バイト(x86)
dim st, 4    ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; wDelay : WORD (+0, 2byte)  wpoke st,0,値  /  値 = wpeek(st,0)
; wResolution : WORD (+2, 2byte)  wpoke st,2,値  /  値 = wpeek(st,2)
; lpFunction : LPTIMECALLBACK (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; dwUser : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; wFlags : WORD (+12, 2byte)  wpoke st,12,値  /  値 = wpeek(st,12)
; wReserved1 : WORD (+14, 2byte)  wpoke st,14,値  /  値 = wpeek(st,14)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; TIMEREVENT サイズ: 20 バイト(x64)
dim st, 5    ; 4byte整数×5(構造体サイズ 20 / 4 切り上げ)
; wDelay : WORD (+0, 2byte)  wpoke st,0,値  /  値 = wpeek(st,0)
; wResolution : WORD (+2, 2byte)  wpoke st,2,値  /  値 = wpeek(st,2)
; lpFunction : LPTIMECALLBACK (+4, 8byte)  qpoke st,4,値 / qpeek(st,4)  ※IronHSPのみ。3.7/3.8は lpoke st,4,下位 : lpoke st,8,上位
; dwUser : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; wFlags : WORD (+16, 2byte)  wpoke st,16,値  /  値 = wpeek(st,16)
; wReserved1 : WORD (+18, 2byte)  wpoke st,18,値  /  値 = wpeek(st,18)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global TIMEREVENT, pack=1
    #field short wDelay
    #field short wResolution
    #field intptr lpFunction
    #field int dwUser
    #field short wFlags
    #field short wReserved1
#endstruct

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