ホーム › Globalization › GetCalendarInfoEx
GetCalendarInfoEx
関数ロケール名を指定してカレンダー情報を取得する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
INT GetCalendarInfoEx(
LPCWSTR lpLocaleName, // optional
DWORD Calendar,
LPCWSTR lpReserved, // optional
DWORD CalType,
LPWSTR lpCalData, // optional
INT cchData,
DWORD* lpValue // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpLocaleName | LPCWSTR | inoptional |
| Calendar | DWORD | in |
| lpReserved | LPCWSTR | inoptional |
| CalType | DWORD | in |
| lpCalData | LPWSTR | outoptional |
| cchData | INT | in |
| lpValue | DWORD* | outoptional |
戻り値の型: INT
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
INT GetCalendarInfoEx(
LPCWSTR lpLocaleName, // optional
DWORD Calendar,
LPCWSTR lpReserved, // optional
DWORD CalType,
LPWSTR lpCalData, // optional
INT cchData,
DWORD* lpValue // optional
);[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern int GetCalendarInfoEx(
[MarshalAs(UnmanagedType.LPWStr)] string lpLocaleName, // LPCWSTR optional
uint Calendar, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string lpReserved, // LPCWSTR optional
uint CalType, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpCalData, // LPWSTR optional, out
int cchData, // INT
IntPtr lpValue // DWORD* optional, out
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetCalendarInfoEx(
<MarshalAs(UnmanagedType.LPWStr)> lpLocaleName As String, ' LPCWSTR optional
Calendar As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> lpReserved As String, ' LPCWSTR optional
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' lpLocaleName : LPCWSTR optional
' Calendar : DWORD
' lpReserved : LPCWSTR optional
' CalType : DWORD
' lpCalData : LPWSTR optional, out
' cchData : INT
' lpValue : DWORD* optional, out
Declare PtrSafe Function GetCalendarInfoEx Lib "kernel32" ( _
ByVal lpLocaleName As LongPtr, _
ByVal Calendar As Long, _
ByVal lpReserved As LongPtr, _
ByVal CalType As Long, _
ByVal lpCalData As LongPtr, _
ByVal cchData As Long, _
ByVal lpValue As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetCalendarInfoEx = ctypes.windll.kernel32.GetCalendarInfoEx
GetCalendarInfoEx.restype = ctypes.c_int
GetCalendarInfoEx.argtypes = [
wintypes.LPCWSTR, # lpLocaleName : LPCWSTR optional
wintypes.DWORD, # Calendar : DWORD
wintypes.LPCWSTR, # lpReserved : LPCWSTR optional
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')
GetCalendarInfoEx = Fiddle::Function.new(
lib['GetCalendarInfoEx'],
[
Fiddle::TYPE_VOIDP, # lpLocaleName : LPCWSTR optional
-Fiddle::TYPE_INT, # Calendar : DWORD
Fiddle::TYPE_VOIDP, # lpReserved : LPCWSTR optional
-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)#[link(name = "kernel32")]
extern "system" {
fn GetCalendarInfoEx(
lpLocaleName: *const u16, // LPCWSTR optional
Calendar: u32, // DWORD
lpReserved: *const u16, // LPCWSTR optional
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", SetLastError = true)]
public static extern int GetCalendarInfoEx([MarshalAs(UnmanagedType.LPWStr)] string lpLocaleName, uint Calendar, [MarshalAs(UnmanagedType.LPWStr)] string lpReserved, uint CalType, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpCalData, int cchData, IntPtr lpValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetCalendarInfoEx' -Namespace Win32 -PassThru
# $api::GetCalendarInfoEx(lpLocaleName, Calendar, lpReserved, CalType, lpCalData, cchData, lpValue)#uselib "KERNEL32.dll"
#func global GetCalendarInfoEx "GetCalendarInfoEx" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; GetCalendarInfoEx lpLocaleName, Calendar, lpReserved, CalType, varptr(lpCalData), cchData, varptr(lpValue) ; 戻り値は stat
; lpLocaleName : LPCWSTR optional -> "sptr"
; Calendar : DWORD -> "sptr"
; lpReserved : LPCWSTR optional -> "sptr"
; CalType : DWORD -> "sptr"
; lpCalData : LPWSTR optional, out -> "sptr"
; cchData : INT -> "sptr"
; lpValue : DWORD* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global GetCalendarInfoEx "GetCalendarInfoEx" wstr, int, wstr, int, var, int, var ; res = GetCalendarInfoEx(lpLocaleName, Calendar, lpReserved, CalType, lpCalData, cchData, lpValue) ; lpLocaleName : LPCWSTR optional -> "wstr" ; Calendar : DWORD -> "int" ; lpReserved : LPCWSTR optional -> "wstr" ; CalType : DWORD -> "int" ; lpCalData : LPWSTR optional, out -> "var" ; cchData : INT -> "int" ; lpValue : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global GetCalendarInfoEx "GetCalendarInfoEx" wstr, int, wstr, int, sptr, int, sptr ; res = GetCalendarInfoEx(lpLocaleName, Calendar, lpReserved, CalType, varptr(lpCalData), cchData, varptr(lpValue)) ; lpLocaleName : LPCWSTR optional -> "wstr" ; Calendar : DWORD -> "int" ; lpReserved : LPCWSTR optional -> "wstr" ; CalType : DWORD -> "int" ; lpCalData : LPWSTR optional, out -> "sptr" ; cchData : INT -> "int" ; lpValue : DWORD* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT GetCalendarInfoEx(LPCWSTR lpLocaleName, DWORD Calendar, LPCWSTR lpReserved, DWORD CalType, LPWSTR lpCalData, INT cchData, DWORD* lpValue) #uselib "KERNEL32.dll" #cfunc global GetCalendarInfoEx "GetCalendarInfoEx" wstr, int, wstr, int, var, int, var ; res = GetCalendarInfoEx(lpLocaleName, Calendar, lpReserved, CalType, lpCalData, cchData, lpValue) ; lpLocaleName : LPCWSTR optional -> "wstr" ; Calendar : DWORD -> "int" ; lpReserved : LPCWSTR optional -> "wstr" ; CalType : DWORD -> "int" ; lpCalData : LPWSTR optional, out -> "var" ; cchData : INT -> "int" ; lpValue : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT GetCalendarInfoEx(LPCWSTR lpLocaleName, DWORD Calendar, LPCWSTR lpReserved, DWORD CalType, LPWSTR lpCalData, INT cchData, DWORD* lpValue) #uselib "KERNEL32.dll" #cfunc global GetCalendarInfoEx "GetCalendarInfoEx" wstr, int, wstr, int, intptr, int, intptr ; res = GetCalendarInfoEx(lpLocaleName, Calendar, lpReserved, CalType, varptr(lpCalData), cchData, varptr(lpValue)) ; lpLocaleName : LPCWSTR optional -> "wstr" ; Calendar : DWORD -> "int" ; lpReserved : LPCWSTR optional -> "wstr" ; 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")
procGetCalendarInfoEx = kernel32.NewProc("GetCalendarInfoEx")
)
// lpLocaleName (LPCWSTR optional), Calendar (DWORD), lpReserved (LPCWSTR optional), CalType (DWORD), lpCalData (LPWSTR optional, out), cchData (INT), lpValue (DWORD* optional, out)
r1, _, err := procGetCalendarInfoEx.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpLocaleName))),
uintptr(Calendar),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpReserved))),
uintptr(CalType),
uintptr(lpCalData),
uintptr(cchData),
uintptr(lpValue),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction GetCalendarInfoEx(
lpLocaleName: PWideChar; // LPCWSTR optional
Calendar: DWORD; // DWORD
lpReserved: PWideChar; // LPCWSTR optional
CalType: DWORD; // DWORD
lpCalData: PWideChar; // LPWSTR optional, out
cchData: Integer; // INT
lpValue: Pointer // DWORD* optional, out
): Integer; stdcall;
external 'KERNEL32.dll' name 'GetCalendarInfoEx';result := DllCall("KERNEL32\GetCalendarInfoEx"
, "WStr", lpLocaleName ; LPCWSTR optional
, "UInt", Calendar ; DWORD
, "WStr", lpReserved ; LPCWSTR optional
, "UInt", CalType ; DWORD
, "Ptr", lpCalData ; LPWSTR optional, out
, "Int", cchData ; INT
, "Ptr", lpValue ; DWORD* optional, out
, "Int") ; return: INT●GetCalendarInfoEx(lpLocaleName, Calendar, lpReserved, CalType, lpCalData, cchData, lpValue) = DLL("KERNEL32.dll", "int GetCalendarInfoEx(char*, dword, char*, dword, char*, int, void*)")
# 呼び出し: GetCalendarInfoEx(lpLocaleName, Calendar, lpReserved, CalType, lpCalData, cchData, lpValue)
# lpLocaleName : LPCWSTR optional -> "char*"
# Calendar : DWORD -> "dword"
# lpReserved : LPCWSTR optional -> "char*"
# 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)。