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

DBTIMESTAMP

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

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

フィールド

フィールドサイズx64x86説明
yearSHORT2+0+0年(西暦、SHORT)。
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秒の小数部をナノ秒単位で表した値(DWORD)。

各言語での定義

#include <windows.h>

// DBTIMESTAMP  (x64 16 / x86 16 バイト)
#pragma pack(push, 2)
typedef struct DBTIMESTAMP {
    SHORT year;
    WORD month;
    WORD day;
    WORD hour;
    WORD minute;
    WORD second;
    DWORD fraction;
} DBTIMESTAMP;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Unicode)]
public struct DBTIMESTAMP
{
    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, Pack:=2, CharSet:=CharSet.Unicode)>
Public Structure DBTIMESTAMP
    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 DBTIMESTAMP(ctypes.Structure):
    _pack_ = 2
    _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, packed(2))]
pub struct DBTIMESTAMP {
    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 DBTIMESTAMP struct {
	year int16
	month uint16
	day uint16
	hour uint16
	minute uint16
	second uint16
	fraction uint32
}
type
  DBTIMESTAMP = packed record
    year: Smallint;
    month: Word;
    day: Word;
    hour: Word;
    minute: Word;
    second: Word;
    fraction: DWORD;
  end;
const DBTIMESTAMP = extern struct {
    year: i16,
    month: u16,
    day: u16,
    hour: u16,
    minute: u16,
    second: u16,
    fraction: u32,
};
type
  DBTIMESTAMP {.packed.} = object
    year: int16
    month: uint16
    day: uint16
    hour: uint16
    minute: uint16
    second: uint16
    fraction: uint32
align(2)
struct DBTIMESTAMP
{
    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 レイアウト)
; DBTIMESTAMP サイズ: 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 DBTIMESTAMP, pack=2
    #field short year
    #field short month
    #field short day
    #field short hour
    #field short minute
    #field short second
    #field int fraction
#endstruct

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