ホーム › Globalization › GetCalendarInfoW
GetCalendarInfoW
関数指定ロケールと暦のカレンダー情報を取得する。Unicode版。
シグネチャ
// KERNEL32.dll (Unicode / -W)
#include <windows.h>
INT GetCalendarInfoW(
DWORD Locale,
DWORD Calendar,
DWORD CalType,
LPWSTR lpCalData, // optional
INT cchData,
DWORD* lpValue // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| Locale | DWORD | in |
| Calendar | DWORD | in |
| CalType | DWORD | in |
| lpCalData | LPWSTR | outoptional |
| cchData | INT | in |
| lpValue | DWORD* | outoptional |
戻り値の型: INT
各言語での呼び出し定義
// KERNEL32.dll (Unicode / -W)
#include <windows.h>
INT GetCalendarInfoW(
DWORD Locale,
DWORD Calendar,
DWORD CalType,
LPWSTR lpCalData, // optional
INT cchData,
DWORD* lpValue // optional
);[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern int GetCalendarInfoW(
uint Locale, // DWORD
uint Calendar, // DWORD
uint CalType, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpCalData, // LPWSTR optional, out
int cchData, // INT
IntPtr lpValue // DWORD* optional, out
);<DllImport("KERNEL32.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetCalendarInfoW(
Locale As UInteger, ' DWORD
Calendar As UInteger, ' DWORD
CalType As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> lpCalData As System.Text.StringBuilder, ' LPWSTR optional, out
cchData As Integer, ' INT
lpValue As IntPtr ' DWORD* optional, out
) As Integer
End Function' Locale : DWORD
' Calendar : DWORD
' CalType : DWORD
' lpCalData : LPWSTR optional, out
' cchData : INT
' lpValue : DWORD* optional, out
Declare PtrSafe Function GetCalendarInfoW Lib "kernel32" ( _
ByVal Locale As Long, _
ByVal Calendar As Long, _
ByVal CalType As Long, _
ByVal lpCalData As LongPtr, _
ByVal cchData As Long, _
ByVal lpValue As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetCalendarInfoW = ctypes.windll.kernel32.GetCalendarInfoW
GetCalendarInfoW.restype = ctypes.c_int
GetCalendarInfoW.argtypes = [
wintypes.DWORD, # Locale : DWORD
wintypes.DWORD, # Calendar : DWORD
wintypes.DWORD, # CalType : DWORD
wintypes.LPWSTR, # lpCalData : LPWSTR optional, out
ctypes.c_int, # cchData : INT
ctypes.POINTER(wintypes.DWORD), # lpValue : DWORD* optional, out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
GetCalendarInfoW = Fiddle::Function.new(
lib['GetCalendarInfoW'],
[
-Fiddle::TYPE_INT, # Locale : DWORD
-Fiddle::TYPE_INT, # Calendar : DWORD
-Fiddle::TYPE_INT, # CalType : DWORD
Fiddle::TYPE_VOIDP, # lpCalData : LPWSTR optional, out
Fiddle::TYPE_INT, # cchData : INT
Fiddle::TYPE_VOIDP, # lpValue : DWORD* optional, out
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "kernel32")]
extern "system" {
fn GetCalendarInfoW(
Locale: u32, // DWORD
Calendar: u32, // DWORD
CalType: u32, // DWORD
lpCalData: *mut u16, // LPWSTR optional, out
cchData: i32, // INT
lpValue: *mut u32 // DWORD* optional, out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern int GetCalendarInfoW(uint Locale, uint Calendar, uint CalType, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpCalData, int cchData, IntPtr lpValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetCalendarInfoW' -Namespace Win32 -PassThru
# $api::GetCalendarInfoW(Locale, Calendar, CalType, lpCalData, cchData, lpValue)#uselib "KERNEL32.dll"
#func global GetCalendarInfoW "GetCalendarInfoW" wptr, wptr, wptr, wptr, wptr, wptr
; GetCalendarInfoW Locale, Calendar, CalType, varptr(lpCalData), cchData, varptr(lpValue) ; 戻り値は stat
; Locale : DWORD -> "wptr"
; Calendar : DWORD -> "wptr"
; CalType : DWORD -> "wptr"
; lpCalData : LPWSTR optional, out -> "wptr"
; cchData : INT -> "wptr"
; lpValue : DWORD* optional, out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global GetCalendarInfoW "GetCalendarInfoW" int, int, int, var, int, var ; res = GetCalendarInfoW(Locale, Calendar, CalType, lpCalData, cchData, lpValue) ; Locale : DWORD -> "int" ; Calendar : DWORD -> "int" ; CalType : DWORD -> "int" ; lpCalData : LPWSTR optional, out -> "var" ; cchData : INT -> "int" ; lpValue : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global GetCalendarInfoW "GetCalendarInfoW" int, int, int, sptr, int, sptr ; res = GetCalendarInfoW(Locale, Calendar, CalType, varptr(lpCalData), cchData, varptr(lpValue)) ; Locale : DWORD -> "int" ; Calendar : DWORD -> "int" ; CalType : DWORD -> "int" ; lpCalData : LPWSTR optional, out -> "sptr" ; cchData : INT -> "int" ; lpValue : DWORD* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT GetCalendarInfoW(DWORD Locale, DWORD Calendar, DWORD CalType, LPWSTR lpCalData, INT cchData, DWORD* lpValue) #uselib "KERNEL32.dll" #cfunc global GetCalendarInfoW "GetCalendarInfoW" int, int, int, var, int, var ; res = GetCalendarInfoW(Locale, Calendar, CalType, lpCalData, cchData, lpValue) ; Locale : DWORD -> "int" ; Calendar : DWORD -> "int" ; CalType : DWORD -> "int" ; lpCalData : LPWSTR optional, out -> "var" ; cchData : INT -> "int" ; lpValue : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT GetCalendarInfoW(DWORD Locale, DWORD Calendar, DWORD CalType, LPWSTR lpCalData, INT cchData, DWORD* lpValue) #uselib "KERNEL32.dll" #cfunc global GetCalendarInfoW "GetCalendarInfoW" int, int, int, intptr, int, intptr ; res = GetCalendarInfoW(Locale, Calendar, CalType, varptr(lpCalData), cchData, varptr(lpValue)) ; Locale : DWORD -> "int" ; Calendar : DWORD -> "int" ; CalType : DWORD -> "int" ; lpCalData : LPWSTR optional, out -> "intptr" ; cchData : INT -> "int" ; lpValue : DWORD* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procGetCalendarInfoW = kernel32.NewProc("GetCalendarInfoW")
)
// Locale (DWORD), Calendar (DWORD), CalType (DWORD), lpCalData (LPWSTR optional, out), cchData (INT), lpValue (DWORD* optional, out)
r1, _, err := procGetCalendarInfoW.Call(
uintptr(Locale),
uintptr(Calendar),
uintptr(CalType),
uintptr(lpCalData),
uintptr(cchData),
uintptr(lpValue),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction GetCalendarInfoW(
Locale: DWORD; // DWORD
Calendar: DWORD; // DWORD
CalType: DWORD; // DWORD
lpCalData: PWideChar; // LPWSTR optional, out
cchData: Integer; // INT
lpValue: Pointer // DWORD* optional, out
): Integer; stdcall;
external 'KERNEL32.dll' name 'GetCalendarInfoW';result := DllCall("KERNEL32\GetCalendarInfoW"
, "UInt", Locale ; DWORD
, "UInt", Calendar ; DWORD
, "UInt", CalType ; DWORD
, "Ptr", lpCalData ; LPWSTR optional, out
, "Int", cchData ; INT
, "Ptr", lpValue ; DWORD* optional, out
, "Int") ; return: INT●GetCalendarInfoW(Locale, Calendar, CalType, lpCalData, cchData, lpValue) = DLL("KERNEL32.dll", "int GetCalendarInfoW(dword, dword, dword, char*, int, void*)")
# 呼び出し: GetCalendarInfoW(Locale, Calendar, CalType, lpCalData, cchData, lpValue)
# Locale : DWORD -> "dword"
# Calendar : DWORD -> "dword"
# CalType : DWORD -> "dword"
# lpCalData : LPWSTR optional, out -> "char*"
# cchData : INT -> "int"
# lpValue : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。