ホーム › Globalization › SetLocaleInfoW
SetLocaleInfoW
関数ユーザーロケールの項目を設定する。Unicode版。
シグネチャ
// KERNEL32.dll (Unicode / -W)
#include <windows.h>
BOOL SetLocaleInfoW(
DWORD Locale,
DWORD LCType,
LPCWSTR lpLCData
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| Locale | DWORD | in |
| LCType | DWORD | in |
| lpLCData | LPCWSTR | in |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll (Unicode / -W)
#include <windows.h>
BOOL SetLocaleInfoW(
DWORD Locale,
DWORD LCType,
LPCWSTR lpLCData
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool SetLocaleInfoW(
uint Locale, // DWORD
uint LCType, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string lpLCData // LPCWSTR
);<DllImport("KERNEL32.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetLocaleInfoW(
Locale As UInteger, ' DWORD
LCType As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> lpLCData As String ' LPCWSTR
) As Boolean
End Function' Locale : DWORD
' LCType : DWORD
' lpLCData : LPCWSTR
Declare PtrSafe Function SetLocaleInfoW Lib "kernel32" ( _
ByVal Locale As Long, _
ByVal LCType As Long, _
ByVal lpLCData 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
SetLocaleInfoW = ctypes.windll.kernel32.SetLocaleInfoW
SetLocaleInfoW.restype = wintypes.BOOL
SetLocaleInfoW.argtypes = [
wintypes.DWORD, # Locale : DWORD
wintypes.DWORD, # LCType : DWORD
wintypes.LPCWSTR, # lpLCData : LPCWSTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
SetLocaleInfoW = Fiddle::Function.new(
lib['SetLocaleInfoW'],
[
-Fiddle::TYPE_INT, # Locale : DWORD
-Fiddle::TYPE_INT, # LCType : DWORD
Fiddle::TYPE_VOIDP, # lpLCData : LPCWSTR
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "kernel32")]
extern "system" {
fn SetLocaleInfoW(
Locale: u32, // DWORD
LCType: u32, // DWORD
lpLCData: *const u16 // LPCWSTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool SetLocaleInfoW(uint Locale, uint LCType, [MarshalAs(UnmanagedType.LPWStr)] string lpLCData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_SetLocaleInfoW' -Namespace Win32 -PassThru
# $api::SetLocaleInfoW(Locale, LCType, lpLCData)#uselib "KERNEL32.dll"
#func global SetLocaleInfoW "SetLocaleInfoW" wptr, wptr, wptr
; SetLocaleInfoW Locale, LCType, lpLCData ; 戻り値は stat
; Locale : DWORD -> "wptr"
; LCType : DWORD -> "wptr"
; lpLCData : LPCWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global SetLocaleInfoW "SetLocaleInfoW" int, int, wstr
; res = SetLocaleInfoW(Locale, LCType, lpLCData)
; Locale : DWORD -> "int"
; LCType : DWORD -> "int"
; lpLCData : LPCWSTR -> "wstr"; BOOL SetLocaleInfoW(DWORD Locale, DWORD LCType, LPCWSTR lpLCData)
#uselib "KERNEL32.dll"
#cfunc global SetLocaleInfoW "SetLocaleInfoW" int, int, wstr
; res = SetLocaleInfoW(Locale, LCType, lpLCData)
; Locale : DWORD -> "int"
; LCType : DWORD -> "int"
; lpLCData : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procSetLocaleInfoW = kernel32.NewProc("SetLocaleInfoW")
)
// Locale (DWORD), LCType (DWORD), lpLCData (LPCWSTR)
r1, _, err := procSetLocaleInfoW.Call(
uintptr(Locale),
uintptr(LCType),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpLCData))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetLocaleInfoW(
Locale: DWORD; // DWORD
LCType: DWORD; // DWORD
lpLCData: PWideChar // LPCWSTR
): BOOL; stdcall;
external 'KERNEL32.dll' name 'SetLocaleInfoW';result := DllCall("KERNEL32\SetLocaleInfoW"
, "UInt", Locale ; DWORD
, "UInt", LCType ; DWORD
, "WStr", lpLCData ; LPCWSTR
, "Int") ; return: BOOL●SetLocaleInfoW(Locale, LCType, lpLCData) = DLL("KERNEL32.dll", "bool SetLocaleInfoW(dword, dword, char*)")
# 呼び出し: SetLocaleInfoW(Locale, LCType, lpLCData)
# Locale : DWORD -> "dword"
# LCType : DWORD -> "dword"
# lpLCData : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。