ホーム › Globalization › NotifyUILanguageChange
NotifyUILanguageChange
関数UI言語の変更をシステムに通知する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
BOOL NotifyUILanguageChange(
DWORD dwFlags,
LPCWSTR pcwstrNewLanguage, // optional
LPCWSTR pcwstrPreviousLanguage, // optional
DWORD dwReserved,
DWORD* pdwStatusRtrn // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| dwFlags | DWORD | in |
| pcwstrNewLanguage | LPCWSTR | inoptional |
| pcwstrPreviousLanguage | LPCWSTR | inoptional |
| dwReserved | DWORD | in |
| pdwStatusRtrn | DWORD* | outoptional |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
BOOL NotifyUILanguageChange(
DWORD dwFlags,
LPCWSTR pcwstrNewLanguage, // optional
LPCWSTR pcwstrPreviousLanguage, // optional
DWORD dwReserved,
DWORD* pdwStatusRtrn // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern bool NotifyUILanguageChange(
uint dwFlags, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string pcwstrNewLanguage, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string pcwstrPreviousLanguage, // LPCWSTR optional
uint dwReserved, // DWORD
IntPtr pdwStatusRtrn // DWORD* optional, out
);<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function NotifyUILanguageChange(
dwFlags As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> pcwstrNewLanguage As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> pcwstrPreviousLanguage As String, ' LPCWSTR optional
dwReserved As UInteger, ' DWORD
pdwStatusRtrn As IntPtr ' DWORD* optional, out
) As Boolean
End Function' dwFlags : DWORD
' pcwstrNewLanguage : LPCWSTR optional
' pcwstrPreviousLanguage : LPCWSTR optional
' dwReserved : DWORD
' pdwStatusRtrn : DWORD* optional, out
Declare PtrSafe Function NotifyUILanguageChange Lib "kernel32" ( _
ByVal dwFlags As Long, _
ByVal pcwstrNewLanguage As LongPtr, _
ByVal pcwstrPreviousLanguage As LongPtr, _
ByVal dwReserved As Long, _
ByVal pdwStatusRtrn As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
NotifyUILanguageChange = ctypes.windll.kernel32.NotifyUILanguageChange
NotifyUILanguageChange.restype = wintypes.BOOL
NotifyUILanguageChange.argtypes = [
wintypes.DWORD, # dwFlags : DWORD
wintypes.LPCWSTR, # pcwstrNewLanguage : LPCWSTR optional
wintypes.LPCWSTR, # pcwstrPreviousLanguage : LPCWSTR optional
wintypes.DWORD, # dwReserved : DWORD
ctypes.POINTER(wintypes.DWORD), # pdwStatusRtrn : DWORD* optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
NotifyUILanguageChange = Fiddle::Function.new(
lib['NotifyUILanguageChange'],
[
-Fiddle::TYPE_INT, # dwFlags : DWORD
Fiddle::TYPE_VOIDP, # pcwstrNewLanguage : LPCWSTR optional
Fiddle::TYPE_VOIDP, # pcwstrPreviousLanguage : LPCWSTR optional
-Fiddle::TYPE_INT, # dwReserved : DWORD
Fiddle::TYPE_VOIDP, # pdwStatusRtrn : DWORD* optional, out
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn NotifyUILanguageChange(
dwFlags: u32, // DWORD
pcwstrNewLanguage: *const u16, // LPCWSTR optional
pcwstrPreviousLanguage: *const u16, // LPCWSTR optional
dwReserved: u32, // DWORD
pdwStatusRtrn: *mut u32 // DWORD* optional, out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll")]
public static extern bool NotifyUILanguageChange(uint dwFlags, [MarshalAs(UnmanagedType.LPWStr)] string pcwstrNewLanguage, [MarshalAs(UnmanagedType.LPWStr)] string pcwstrPreviousLanguage, uint dwReserved, IntPtr pdwStatusRtrn);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_NotifyUILanguageChange' -Namespace Win32 -PassThru
# $api::NotifyUILanguageChange(dwFlags, pcwstrNewLanguage, pcwstrPreviousLanguage, dwReserved, pdwStatusRtrn)#uselib "KERNEL32.dll"
#func global NotifyUILanguageChange "NotifyUILanguageChange" sptr, sptr, sptr, sptr, sptr
; NotifyUILanguageChange dwFlags, pcwstrNewLanguage, pcwstrPreviousLanguage, dwReserved, varptr(pdwStatusRtrn) ; 戻り値は stat
; dwFlags : DWORD -> "sptr"
; pcwstrNewLanguage : LPCWSTR optional -> "sptr"
; pcwstrPreviousLanguage : LPCWSTR optional -> "sptr"
; dwReserved : DWORD -> "sptr"
; pdwStatusRtrn : DWORD* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global NotifyUILanguageChange "NotifyUILanguageChange" int, wstr, wstr, int, var ; res = NotifyUILanguageChange(dwFlags, pcwstrNewLanguage, pcwstrPreviousLanguage, dwReserved, pdwStatusRtrn) ; dwFlags : DWORD -> "int" ; pcwstrNewLanguage : LPCWSTR optional -> "wstr" ; pcwstrPreviousLanguage : LPCWSTR optional -> "wstr" ; dwReserved : DWORD -> "int" ; pdwStatusRtrn : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global NotifyUILanguageChange "NotifyUILanguageChange" int, wstr, wstr, int, sptr ; res = NotifyUILanguageChange(dwFlags, pcwstrNewLanguage, pcwstrPreviousLanguage, dwReserved, varptr(pdwStatusRtrn)) ; dwFlags : DWORD -> "int" ; pcwstrNewLanguage : LPCWSTR optional -> "wstr" ; pcwstrPreviousLanguage : LPCWSTR optional -> "wstr" ; dwReserved : DWORD -> "int" ; pdwStatusRtrn : DWORD* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL NotifyUILanguageChange(DWORD dwFlags, LPCWSTR pcwstrNewLanguage, LPCWSTR pcwstrPreviousLanguage, DWORD dwReserved, DWORD* pdwStatusRtrn) #uselib "KERNEL32.dll" #cfunc global NotifyUILanguageChange "NotifyUILanguageChange" int, wstr, wstr, int, var ; res = NotifyUILanguageChange(dwFlags, pcwstrNewLanguage, pcwstrPreviousLanguage, dwReserved, pdwStatusRtrn) ; dwFlags : DWORD -> "int" ; pcwstrNewLanguage : LPCWSTR optional -> "wstr" ; pcwstrPreviousLanguage : LPCWSTR optional -> "wstr" ; dwReserved : DWORD -> "int" ; pdwStatusRtrn : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL NotifyUILanguageChange(DWORD dwFlags, LPCWSTR pcwstrNewLanguage, LPCWSTR pcwstrPreviousLanguage, DWORD dwReserved, DWORD* pdwStatusRtrn) #uselib "KERNEL32.dll" #cfunc global NotifyUILanguageChange "NotifyUILanguageChange" int, wstr, wstr, int, intptr ; res = NotifyUILanguageChange(dwFlags, pcwstrNewLanguage, pcwstrPreviousLanguage, dwReserved, varptr(pdwStatusRtrn)) ; dwFlags : DWORD -> "int" ; pcwstrNewLanguage : LPCWSTR optional -> "wstr" ; pcwstrPreviousLanguage : LPCWSTR optional -> "wstr" ; dwReserved : DWORD -> "int" ; pdwStatusRtrn : DWORD* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procNotifyUILanguageChange = kernel32.NewProc("NotifyUILanguageChange")
)
// dwFlags (DWORD), pcwstrNewLanguage (LPCWSTR optional), pcwstrPreviousLanguage (LPCWSTR optional), dwReserved (DWORD), pdwStatusRtrn (DWORD* optional, out)
r1, _, err := procNotifyUILanguageChange.Call(
uintptr(dwFlags),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pcwstrNewLanguage))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pcwstrPreviousLanguage))),
uintptr(dwReserved),
uintptr(pdwStatusRtrn),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction NotifyUILanguageChange(
dwFlags: DWORD; // DWORD
pcwstrNewLanguage: PWideChar; // LPCWSTR optional
pcwstrPreviousLanguage: PWideChar; // LPCWSTR optional
dwReserved: DWORD; // DWORD
pdwStatusRtrn: Pointer // DWORD* optional, out
): BOOL; stdcall;
external 'KERNEL32.dll' name 'NotifyUILanguageChange';result := DllCall("KERNEL32\NotifyUILanguageChange"
, "UInt", dwFlags ; DWORD
, "WStr", pcwstrNewLanguage ; LPCWSTR optional
, "WStr", pcwstrPreviousLanguage ; LPCWSTR optional
, "UInt", dwReserved ; DWORD
, "Ptr", pdwStatusRtrn ; DWORD* optional, out
, "Int") ; return: BOOL●NotifyUILanguageChange(dwFlags, pcwstrNewLanguage, pcwstrPreviousLanguage, dwReserved, pdwStatusRtrn) = DLL("KERNEL32.dll", "bool NotifyUILanguageChange(dword, char*, char*, dword, void*)")
# 呼び出し: NotifyUILanguageChange(dwFlags, pcwstrNewLanguage, pcwstrPreviousLanguage, dwReserved, pdwStatusRtrn)
# dwFlags : DWORD -> "dword"
# pcwstrNewLanguage : LPCWSTR optional -> "char*"
# pcwstrPreviousLanguage : LPCWSTR optional -> "char*"
# dwReserved : DWORD -> "dword"
# pdwStatusRtrn : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。