Win32 API 日本語リファレンス
ホームNetworking.WindowsWebServices › WS_DURATION

WS_DURATION

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

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

フィールド

フィールドサイズx64x86説明
negativeBOOL4+0+0期間が負(過去方向)であればTRUEを示すブール値。
yearsDWORD4+4+4期間に含まれる年数。
monthsDWORD4+8+8期間に含まれる月数。
daysDWORD4+12+12期間に含まれる日数。
hoursDWORD4+16+16期間に含まれる時間数。
minutesDWORD4+20+20期間に含まれる分数。
secondsDWORD4+24+24期間に含まれる秒数。
millisecondsDWORD4+28+28期間に含まれるミリ秒数。
ticksDWORD4+32+32期間に含まれる100ナノ秒単位のティック数。

各言語での定義

#include <windows.h>

// WS_DURATION  (x64 36 / x86 36 バイト)
typedef struct WS_DURATION {
    BOOL negative;
    DWORD years;
    DWORD months;
    DWORD days;
    DWORD hours;
    DWORD minutes;
    DWORD seconds;
    DWORD milliseconds;
    DWORD ticks;
} WS_DURATION;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WS_DURATION
{
    [MarshalAs(UnmanagedType.Bool)] public bool negative;
    public uint years;
    public uint months;
    public uint days;
    public uint hours;
    public uint minutes;
    public uint seconds;
    public uint milliseconds;
    public uint ticks;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WS_DURATION
    <MarshalAs(UnmanagedType.Bool)> Public negative As Boolean
    Public years As UInteger
    Public months As UInteger
    Public days As UInteger
    Public hours As UInteger
    Public minutes As UInteger
    Public seconds As UInteger
    Public milliseconds As UInteger
    Public ticks As UInteger
End Structure
import ctypes
from ctypes import wintypes

class WS_DURATION(ctypes.Structure):
    _fields_ = [
        ("negative", wintypes.BOOL),
        ("years", wintypes.DWORD),
        ("months", wintypes.DWORD),
        ("days", wintypes.DWORD),
        ("hours", wintypes.DWORD),
        ("minutes", wintypes.DWORD),
        ("seconds", wintypes.DWORD),
        ("milliseconds", wintypes.DWORD),
        ("ticks", wintypes.DWORD),
    ]
#[repr(C)]
pub struct WS_DURATION {
    pub negative: i32,
    pub years: u32,
    pub months: u32,
    pub days: u32,
    pub hours: u32,
    pub minutes: u32,
    pub seconds: u32,
    pub milliseconds: u32,
    pub ticks: u32,
}
import "golang.org/x/sys/windows"

type WS_DURATION struct {
	negative int32
	years uint32
	months uint32
	days uint32
	hours uint32
	minutes uint32
	seconds uint32
	milliseconds uint32
	ticks uint32
}
type
  WS_DURATION = record
    negative: BOOL;
    years: DWORD;
    months: DWORD;
    days: DWORD;
    hours: DWORD;
    minutes: DWORD;
    seconds: DWORD;
    milliseconds: DWORD;
    ticks: DWORD;
  end;
const WS_DURATION = extern struct {
    negative: i32,
    years: u32,
    months: u32,
    days: u32,
    hours: u32,
    minutes: u32,
    seconds: u32,
    milliseconds: u32,
    ticks: u32,
};
type
  WS_DURATION {.bycopy.} = object
    negative: int32
    years: uint32
    months: uint32
    days: uint32
    hours: uint32
    minutes: uint32
    seconds: uint32
    milliseconds: uint32
    ticks: uint32
struct WS_DURATION
{
    int negative;
    uint years;
    uint months;
    uint days;
    uint hours;
    uint minutes;
    uint seconds;
    uint milliseconds;
    uint ticks;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WS_DURATION サイズ: 36 バイト(x64)
dim st, 9    ; 4byte整数×9(構造体サイズ 36 / 4 切り上げ)
; negative : BOOL (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; years : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; months : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; days : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; hours : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; minutes : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; seconds : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; milliseconds : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; ticks : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global WS_DURATION
    #field bool negative
    #field int years
    #field int months
    #field int days
    #field int hours
    #field int minutes
    #field int seconds
    #field int milliseconds
    #field int ticks
#endstruct

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