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

TIMESTAMP_STRUCT

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

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

フィールド

フィールドサイズx64x86説明
yearSHORT2+0+0年。西暦の数値で格納する。
monthWORD2+2+2月。1〜12 の値。
dayWORD2+4+4日。1〜31 の値。
hourWORD2+6+6時。0〜23 の値。
minuteWORD2+8+8分。0〜59 の値。
secondWORD2+10+10秒。0〜59 の値。
fractionDWORD4+12+12秒の小数部。ナノ秒単位で格納する。

各言語での定義

#include <windows.h>

// TIMESTAMP_STRUCT  (x64 16 / x86 16 バイト)
typedef struct TIMESTAMP_STRUCT {
    SHORT year;
    WORD month;
    WORD day;
    WORD hour;
    WORD minute;
    WORD second;
    DWORD fraction;
} TIMESTAMP_STRUCT;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct TIMESTAMP_STRUCT
{
    public short year;
    public ushort month;
    public ushort day;
    public ushort hour;
    public ushort minute;
    public ushort second;
    public uint fraction;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure TIMESTAMP_STRUCT
    Public year As Short
    Public month As UShort
    Public day As UShort
    Public hour As UShort
    Public minute As UShort
    Public second As UShort
    Public fraction As UInteger
End Structure
import ctypes
from ctypes import wintypes

class TIMESTAMP_STRUCT(ctypes.Structure):
    _fields_ = [
        ("year", ctypes.c_short),
        ("month", ctypes.c_ushort),
        ("day", ctypes.c_ushort),
        ("hour", ctypes.c_ushort),
        ("minute", ctypes.c_ushort),
        ("second", ctypes.c_ushort),
        ("fraction", wintypes.DWORD),
    ]
#[repr(C)]
pub struct TIMESTAMP_STRUCT {
    pub year: i16,
    pub month: u16,
    pub day: u16,
    pub hour: u16,
    pub minute: u16,
    pub second: u16,
    pub fraction: u32,
}
import "golang.org/x/sys/windows"

type TIMESTAMP_STRUCT struct {
	year int16
	month uint16
	day uint16
	hour uint16
	minute uint16
	second uint16
	fraction uint32
}
type
  TIMESTAMP_STRUCT = record
    year: Smallint;
    month: Word;
    day: Word;
    hour: Word;
    minute: Word;
    second: Word;
    fraction: DWORD;
  end;
const TIMESTAMP_STRUCT = extern struct {
    year: i16,
    month: u16,
    day: u16,
    hour: u16,
    minute: u16,
    second: u16,
    fraction: u32,
};
type
  TIMESTAMP_STRUCT {.bycopy.} = object
    year: int16
    month: uint16
    day: uint16
    hour: uint16
    minute: uint16
    second: uint16
    fraction: uint32
struct TIMESTAMP_STRUCT
{
    short year;
    ushort month;
    ushort day;
    ushort hour;
    ushort minute;
    ushort second;
    uint fraction;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; TIMESTAMP_STRUCT サイズ: 16 バイト(x64)
dim st, 4    ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; year : SHORT (+0, 2byte)  wpoke st,0,値  /  値 = wpeek(st,0)
; month : WORD (+2, 2byte)  wpoke st,2,値  /  値 = wpeek(st,2)
; day : WORD (+4, 2byte)  wpoke st,4,値  /  値 = wpeek(st,4)
; hour : WORD (+6, 2byte)  wpoke st,6,値  /  値 = wpeek(st,6)
; minute : WORD (+8, 2byte)  wpoke st,8,値  /  値 = wpeek(st,8)
; second : WORD (+10, 2byte)  wpoke st,10,値  /  値 = wpeek(st,10)
; fraction : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global TIMESTAMP_STRUCT
    #field short year
    #field short month
    #field short day
    #field short hour
    #field short minute
    #field short second
    #field int fraction
#endstruct

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