ホーム › 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 | DWORD 型の戻りステータスへのポインター。 |
戻り値の型: BOOL
公式ドキュメント
サポートされていません。NotifyUILanguageChange は変更されるか、利用できなくなる可能性があります。
戻り値
BOOL データ型。
解説(Remarks)
NotifyUILanguageChange はサポートされておらず、将来変更されるか、利用できなくなる可能性があります。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// 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 <MarshalAs(UnmanagedType.Bool)> 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)。const std = @import("std");
extern "kernel32" fn NotifyUILanguageChange(
dwFlags: u32, // DWORD
pcwstrNewLanguage: [*c]const u16, // LPCWSTR optional
pcwstrPreviousLanguage: [*c]const u16, // LPCWSTR optional
dwReserved: u32, // DWORD
pdwStatusRtrn: [*c]u32 // DWORD* optional, out
) callconv(std.os.windows.WINAPI) i32;proc NotifyUILanguageChange(
dwFlags: uint32, # DWORD
pcwstrNewLanguage: WideCString, # LPCWSTR optional
pcwstrPreviousLanguage: WideCString, # LPCWSTR optional
dwReserved: uint32, # DWORD
pdwStatusRtrn: ptr uint32 # DWORD* optional, out
): int32 {.importc: "NotifyUILanguageChange", stdcall, dynlib: "KERNEL32.dll".}pragma(lib, "kernel32");
extern(Windows)
int NotifyUILanguageChange(
uint dwFlags, // DWORD
const(wchar)* pcwstrNewLanguage, // LPCWSTR optional
const(wchar)* pcwstrPreviousLanguage, // LPCWSTR optional
uint dwReserved, // DWORD
uint* pdwStatusRtrn // DWORD* optional, out
);ccall((:NotifyUILanguageChange, "KERNEL32.dll"), stdcall, Int32,
(UInt32, Cwstring, Cwstring, UInt32, Ptr{UInt32}),
dwFlags, pcwstrNewLanguage, pcwstrPreviousLanguage, dwReserved, pdwStatusRtrn)
# dwFlags : DWORD -> UInt32
# pcwstrNewLanguage : LPCWSTR optional -> Cwstring
# pcwstrPreviousLanguage : LPCWSTR optional -> Cwstring
# dwReserved : DWORD -> UInt32
# pdwStatusRtrn : DWORD* optional, out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t NotifyUILanguageChange(
uint32_t dwFlags,
const uint16_t* pcwstrNewLanguage,
const uint16_t* pcwstrPreviousLanguage,
uint32_t dwReserved,
uint32_t* pdwStatusRtrn);
]]
local kernel32 = ffi.load("kernel32")
-- kernel32.NotifyUILanguageChange(dwFlags, pcwstrNewLanguage, pcwstrPreviousLanguage, dwReserved, pdwStatusRtrn)
-- dwFlags : DWORD
-- pcwstrNewLanguage : LPCWSTR optional
-- pcwstrPreviousLanguage : LPCWSTR optional
-- dwReserved : DWORD
-- pdwStatusRtrn : DWORD* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('KERNEL32.dll');
const NotifyUILanguageChange = lib.func('__stdcall', 'NotifyUILanguageChange', 'int32_t', ['uint32_t', 'str16', 'str16', 'uint32_t', 'uint32_t *']);
// NotifyUILanguageChange(dwFlags, pcwstrNewLanguage, pcwstrPreviousLanguage, dwReserved, pdwStatusRtrn)
// dwFlags : DWORD -> 'uint32_t'
// pcwstrNewLanguage : LPCWSTR optional -> 'str16'
// pcwstrPreviousLanguage : LPCWSTR optional -> 'str16'
// dwReserved : DWORD -> 'uint32_t'
// pdwStatusRtrn : DWORD* optional, out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("KERNEL32.dll", {
NotifyUILanguageChange: { parameters: ["u32", "buffer", "buffer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.NotifyUILanguageChange(dwFlags, pcwstrNewLanguage, pcwstrPreviousLanguage, dwReserved, pdwStatusRtrn)
// dwFlags : DWORD -> "u32"
// pcwstrNewLanguage : LPCWSTR optional -> "buffer"
// pcwstrPreviousLanguage : LPCWSTR optional -> "buffer"
// dwReserved : DWORD -> "u32"
// pdwStatusRtrn : DWORD* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t NotifyUILanguageChange(
uint32_t dwFlags,
const uint16_t* pcwstrNewLanguage,
const uint16_t* pcwstrPreviousLanguage,
uint32_t dwReserved,
uint32_t* pdwStatusRtrn);
C, "KERNEL32.dll");
// $ffi->NotifyUILanguageChange(dwFlags, pcwstrNewLanguage, pcwstrPreviousLanguage, dwReserved, pdwStatusRtrn);
// dwFlags : DWORD
// pcwstrNewLanguage : LPCWSTR optional
// pcwstrPreviousLanguage : LPCWSTR optional
// dwReserved : DWORD
// pdwStatusRtrn : DWORD* optional, out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Kernel32 extends StdCallLibrary {
Kernel32 INSTANCE = Native.load("kernel32", Kernel32.class);
boolean NotifyUILanguageChange(
int dwFlags, // DWORD
WString pcwstrNewLanguage, // LPCWSTR optional
WString pcwstrPreviousLanguage, // LPCWSTR optional
int dwReserved, // DWORD
IntByReference pdwStatusRtrn // DWORD* optional, out
);
}@[Link("kernel32")]
lib LibKERNEL32
fun NotifyUILanguageChange = NotifyUILanguageChange(
dwFlags : UInt32, # DWORD
pcwstrNewLanguage : UInt16*, # LPCWSTR optional
pcwstrPreviousLanguage : UInt16*, # LPCWSTR optional
dwReserved : UInt32, # DWORD
pdwStatusRtrn : UInt32* # DWORD* optional, out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef NotifyUILanguageChangeNative = Int32 Function(Uint32, Pointer<Utf16>, Pointer<Utf16>, Uint32, Pointer<Uint32>);
typedef NotifyUILanguageChangeDart = int Function(int, Pointer<Utf16>, Pointer<Utf16>, int, Pointer<Uint32>);
final NotifyUILanguageChange = DynamicLibrary.open('KERNEL32.dll')
.lookupFunction<NotifyUILanguageChangeNative, NotifyUILanguageChangeDart>('NotifyUILanguageChange');
// dwFlags : DWORD -> Uint32
// pcwstrNewLanguage : LPCWSTR optional -> Pointer<Utf16>
// pcwstrPreviousLanguage : LPCWSTR optional -> Pointer<Utf16>
// dwReserved : DWORD -> Uint32
// pdwStatusRtrn : DWORD* optional, out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function 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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "NotifyUILanguageChange"
c_NotifyUILanguageChange :: Word32 -> CWString -> CWString -> Word32 -> Ptr Word32 -> IO CInt
-- dwFlags : DWORD -> Word32
-- pcwstrNewLanguage : LPCWSTR optional -> CWString
-- pcwstrPreviousLanguage : LPCWSTR optional -> CWString
-- dwReserved : DWORD -> Word32
-- pdwStatusRtrn : DWORD* optional, out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let notifyuilanguagechange =
foreign "NotifyUILanguageChange"
(uint32_t @-> (ptr uint16_t) @-> (ptr uint16_t) @-> uint32_t @-> (ptr uint32_t) @-> returning int32_t)
(* dwFlags : DWORD -> uint32_t *)
(* pcwstrNewLanguage : LPCWSTR optional -> (ptr uint16_t) *)
(* pcwstrPreviousLanguage : LPCWSTR optional -> (ptr uint16_t) *)
(* dwReserved : DWORD -> uint32_t *)
(* pdwStatusRtrn : DWORD* optional, out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library kernel32 (t "KERNEL32.dll"))
(cffi:use-foreign-library kernel32)
(cffi:defcfun ("NotifyUILanguageChange" notify-uilanguage-change :convention :stdcall) :int32
(dw-flags :uint32) ; DWORD
(pcwstr-new-language (:string :encoding :utf-16le)) ; LPCWSTR optional
(pcwstr-previous-language (:string :encoding :utf-16le)) ; LPCWSTR optional
(dw-reserved :uint32) ; DWORD
(pdw-status-rtrn :pointer)) ; DWORD* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $NotifyUILanguageChange = Win32::API::More->new('KERNEL32',
'BOOL NotifyUILanguageChange(DWORD dwFlags, LPCWSTR pcwstrNewLanguage, LPCWSTR pcwstrPreviousLanguage, DWORD dwReserved, LPVOID pdwStatusRtrn)');
# my $ret = $NotifyUILanguageChange->Call($dwFlags, $pcwstrNewLanguage, $pcwstrPreviousLanguage, $dwReserved, $pdwStatusRtrn);
# dwFlags : DWORD -> DWORD
# pcwstrNewLanguage : LPCWSTR optional -> LPCWSTR
# pcwstrPreviousLanguage : LPCWSTR optional -> LPCWSTR
# dwReserved : DWORD -> DWORD
# pdwStatusRtrn : DWORD* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。