Win32 API 日本語リファレンス
ホームUI.Input.KeyboardAndMouse › UnloadKeyboardLayout

UnloadKeyboardLayout

関数
読み込み済みのキーボードレイアウトを解放する。
DLLUSER32.dll呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

// USER32.dll
#include <windows.h>

BOOL UnloadKeyboardLayout(
    HKL hkl
);

パラメーター

名前方向
hklHKLin

戻り値の型: BOOL

各言語での呼び出し定義

// USER32.dll
#include <windows.h>

BOOL UnloadKeyboardLayout(
    HKL hkl
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool UnloadKeyboardLayout(
    IntPtr hkl   // HKL
);
<DllImport("USER32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function UnloadKeyboardLayout(
    hkl As IntPtr   ' HKL
) As Boolean
End Function
' hkl : HKL
Declare PtrSafe Function UnloadKeyboardLayout Lib "user32" ( _
    ByVal hkl As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

UnloadKeyboardLayout = ctypes.windll.user32.UnloadKeyboardLayout
UnloadKeyboardLayout.restype = wintypes.BOOL
UnloadKeyboardLayout.argtypes = [
    wintypes.HANDLE,  # hkl : HKL
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
UnloadKeyboardLayout = Fiddle::Function.new(
  lib['UnloadKeyboardLayout'],
  [
    Fiddle::TYPE_VOIDP,  # hkl : HKL
  ],
  Fiddle::TYPE_INT)
#[link(name = "user32")]
extern "system" {
    fn UnloadKeyboardLayout(
        hkl: *mut core::ffi::c_void  // HKL
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", SetLastError = true)]
public static extern bool UnloadKeyboardLayout(IntPtr hkl);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_UnloadKeyboardLayout' -Namespace Win32 -PassThru
# $api::UnloadKeyboardLayout(hkl)
#uselib "USER32.dll"
#func global UnloadKeyboardLayout "UnloadKeyboardLayout" sptr
; UnloadKeyboardLayout hkl   ; 戻り値は stat
; hkl : HKL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "USER32.dll"
#cfunc global UnloadKeyboardLayout "UnloadKeyboardLayout" sptr
; res = UnloadKeyboardLayout(hkl)
; hkl : HKL -> "sptr"
; BOOL UnloadKeyboardLayout(HKL hkl)
#uselib "USER32.dll"
#cfunc global UnloadKeyboardLayout "UnloadKeyboardLayout" intptr
; res = UnloadKeyboardLayout(hkl)
; hkl : HKL -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procUnloadKeyboardLayout = user32.NewProc("UnloadKeyboardLayout")
)

// hkl (HKL)
r1, _, err := procUnloadKeyboardLayout.Call(
	uintptr(hkl),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function UnloadKeyboardLayout(
  hkl: THandle   // HKL
): BOOL; stdcall;
  external 'USER32.dll' name 'UnloadKeyboardLayout';
result := DllCall("USER32\UnloadKeyboardLayout"
    , "Ptr", hkl   ; HKL
    , "Int")   ; return: BOOL
●UnloadKeyboardLayout(hkl) = DLL("USER32.dll", "bool UnloadKeyboardLayout(void*)")
# 呼び出し: UnloadKeyboardLayout(hkl)
# hkl : HKL -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。