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

ImmGetHotKey

関数
IMEホットキーの修飾子・仮想キー・キーボードレイアウトを取得する。
DLLIMM32.dll呼出規約winapi

シグネチャ

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

BOOL ImmGetHotKey(
    DWORD param0,
    DWORD* lpuModifiers,
    DWORD* lpuVKey,
    HKL* phKL
);

パラメーター

名前方向説明
param0DWORDin取得対象のIMEホットキーID(IME_HOTKEY_*)。
lpuModifiersDWORD*outホットキーの修飾キー(MOD_*)を受け取るDWORDへのポインタ。
lpuVKeyDWORD*outホットキーの仮想キーコードを受け取るDWORDへのポインタ。
phKLHKL*outホットキーに関連付くキーボードレイアウト(HKL)を受け取るポインタ。

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL ImmGetHotKey(
    DWORD param0,
    DWORD* lpuModifiers,
    DWORD* lpuVKey,
    HKL* phKL
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("IMM32.dll", ExactSpelling = true)]
static extern bool ImmGetHotKey(
    uint param0,   // DWORD
    out uint lpuModifiers,   // DWORD* out
    out uint lpuVKey,   // DWORD* out
    IntPtr phKL   // HKL* out
);
<DllImport("IMM32.dll", ExactSpelling:=True)>
Public Shared Function ImmGetHotKey(
    param0 As UInteger,   ' DWORD
    <Out> ByRef lpuModifiers As UInteger,   ' DWORD* out
    <Out> ByRef lpuVKey As UInteger,   ' DWORD* out
    phKL As IntPtr   ' HKL* out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' param0 : DWORD
' lpuModifiers : DWORD* out
' lpuVKey : DWORD* out
' phKL : HKL* out
Declare PtrSafe Function ImmGetHotKey Lib "imm32" ( _
    ByVal param0 As Long, _
    ByRef lpuModifiers As Long, _
    ByRef lpuVKey As Long, _
    ByVal phKL As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ImmGetHotKey = ctypes.windll.imm32.ImmGetHotKey
ImmGetHotKey.restype = wintypes.BOOL
ImmGetHotKey.argtypes = [
    wintypes.DWORD,  # param0 : DWORD
    ctypes.POINTER(wintypes.DWORD),  # lpuModifiers : DWORD* out
    ctypes.POINTER(wintypes.DWORD),  # lpuVKey : DWORD* out
    ctypes.c_void_p,  # phKL : HKL* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('IMM32.dll')
ImmGetHotKey = Fiddle::Function.new(
  lib['ImmGetHotKey'],
  [
    -Fiddle::TYPE_INT,  # param0 : DWORD
    Fiddle::TYPE_VOIDP,  # lpuModifiers : DWORD* out
    Fiddle::TYPE_VOIDP,  # lpuVKey : DWORD* out
    Fiddle::TYPE_VOIDP,  # phKL : HKL* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "imm32")]
extern "system" {
    fn ImmGetHotKey(
        param0: u32,  // DWORD
        lpuModifiers: *mut u32,  // DWORD* out
        lpuVKey: *mut u32,  // DWORD* out
        phKL: *mut *mut core::ffi::c_void  // HKL* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("IMM32.dll")]
public static extern bool ImmGetHotKey(uint param0, out uint lpuModifiers, out uint lpuVKey, IntPtr phKL);
"@
$api = Add-Type -MemberDefinition $sig -Name 'IMM32_ImmGetHotKey' -Namespace Win32 -PassThru
# $api::ImmGetHotKey(param0, lpuModifiers, lpuVKey, phKL)
#uselib "IMM32.dll"
#func global ImmGetHotKey "ImmGetHotKey" sptr, sptr, sptr, sptr
; ImmGetHotKey param0, varptr(lpuModifiers), varptr(lpuVKey), phKL   ; 戻り値は stat
; param0 : DWORD -> "sptr"
; lpuModifiers : DWORD* out -> "sptr"
; lpuVKey : DWORD* out -> "sptr"
; phKL : HKL* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "IMM32.dll"
#cfunc global ImmGetHotKey "ImmGetHotKey" int, var, var, sptr
; res = ImmGetHotKey(param0, lpuModifiers, lpuVKey, phKL)
; param0 : DWORD -> "int"
; lpuModifiers : DWORD* out -> "var"
; lpuVKey : DWORD* out -> "var"
; phKL : HKL* out -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL ImmGetHotKey(DWORD param0, DWORD* lpuModifiers, DWORD* lpuVKey, HKL* phKL)
#uselib "IMM32.dll"
#cfunc global ImmGetHotKey "ImmGetHotKey" int, var, var, intptr
; res = ImmGetHotKey(param0, lpuModifiers, lpuVKey, phKL)
; param0 : DWORD -> "int"
; lpuModifiers : DWORD* out -> "var"
; lpuVKey : DWORD* out -> "var"
; phKL : HKL* out -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	imm32 = windows.NewLazySystemDLL("IMM32.dll")
	procImmGetHotKey = imm32.NewProc("ImmGetHotKey")
)

// param0 (DWORD), lpuModifiers (DWORD* out), lpuVKey (DWORD* out), phKL (HKL* out)
r1, _, err := procImmGetHotKey.Call(
	uintptr(param0),
	uintptr(lpuModifiers),
	uintptr(lpuVKey),
	uintptr(phKL),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function ImmGetHotKey(
  param0: DWORD;   // DWORD
  lpuModifiers: Pointer;   // DWORD* out
  lpuVKey: Pointer;   // DWORD* out
  phKL: Pointer   // HKL* out
): BOOL; stdcall;
  external 'IMM32.dll' name 'ImmGetHotKey';
result := DllCall("IMM32\ImmGetHotKey"
    , "UInt", param0   ; DWORD
    , "Ptr", lpuModifiers   ; DWORD* out
    , "Ptr", lpuVKey   ; DWORD* out
    , "Ptr", phKL   ; HKL* out
    , "Int")   ; return: BOOL
●ImmGetHotKey(param0, lpuModifiers, lpuVKey, phKL) = DLL("IMM32.dll", "bool ImmGetHotKey(dword, void*, void*, void*)")
# 呼び出し: ImmGetHotKey(param0, lpuModifiers, lpuVKey, phKL)
# param0 : DWORD -> "dword"
# lpuModifiers : DWORD* out -> "void*"
# lpuVKey : DWORD* out -> "void*"
# phKL : HKL* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "imm32" fn ImmGetHotKey(
    param0: u32, // DWORD
    lpuModifiers: [*c]u32, // DWORD* out
    lpuVKey: [*c]u32, // DWORD* out
    phKL: ?*anyopaque // HKL* out
) callconv(std.os.windows.WINAPI) i32;
proc ImmGetHotKey(
    param0: uint32,  # DWORD
    lpuModifiers: ptr uint32,  # DWORD* out
    lpuVKey: ptr uint32,  # DWORD* out
    phKL: pointer  # HKL* out
): int32 {.importc: "ImmGetHotKey", stdcall, dynlib: "IMM32.dll".}
pragma(lib, "imm32");
extern(Windows)
int ImmGetHotKey(
    uint param0,   // DWORD
    uint* lpuModifiers,   // DWORD* out
    uint* lpuVKey,   // DWORD* out
    void* phKL   // HKL* out
);
ccall((:ImmGetHotKey, "IMM32.dll"), stdcall, Int32,
      (UInt32, Ptr{UInt32}, Ptr{UInt32}, Ptr{Cvoid}),
      param0, lpuModifiers, lpuVKey, phKL)
# param0 : DWORD -> UInt32
# lpuModifiers : DWORD* out -> Ptr{UInt32}
# lpuVKey : DWORD* out -> Ptr{UInt32}
# phKL : HKL* out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t ImmGetHotKey(
    uint32_t param0,
    uint32_t* lpuModifiers,
    uint32_t* lpuVKey,
    void* phKL);
]]
local imm32 = ffi.load("imm32")
-- imm32.ImmGetHotKey(param0, lpuModifiers, lpuVKey, phKL)
-- param0 : DWORD
-- lpuModifiers : DWORD* out
-- lpuVKey : DWORD* out
-- phKL : HKL* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('IMM32.dll');
const ImmGetHotKey = lib.func('__stdcall', 'ImmGetHotKey', 'int32_t', ['uint32_t', 'uint32_t *', 'uint32_t *', 'void *']);
// ImmGetHotKey(param0, lpuModifiers, lpuVKey, phKL)
// param0 : DWORD -> 'uint32_t'
// lpuModifiers : DWORD* out -> 'uint32_t *'
// lpuVKey : DWORD* out -> 'uint32_t *'
// phKL : HKL* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("IMM32.dll", {
  ImmGetHotKey: { parameters: ["u32", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.ImmGetHotKey(param0, lpuModifiers, lpuVKey, phKL)
// param0 : DWORD -> "u32"
// lpuModifiers : DWORD* out -> "pointer"
// lpuVKey : DWORD* out -> "pointer"
// phKL : HKL* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t ImmGetHotKey(
    uint32_t param0,
    uint32_t* lpuModifiers,
    uint32_t* lpuVKey,
    void* phKL);
C, "IMM32.dll");
// $ffi->ImmGetHotKey(param0, lpuModifiers, lpuVKey, phKL);
// param0 : DWORD
// lpuModifiers : DWORD* out
// lpuVKey : DWORD* out
// phKL : HKL* 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 Imm32 extends StdCallLibrary {
    Imm32 INSTANCE = Native.load("imm32", Imm32.class);
    boolean ImmGetHotKey(
        int param0,   // DWORD
        IntByReference lpuModifiers,   // DWORD* out
        IntByReference lpuVKey,   // DWORD* out
        Pointer phKL   // HKL* out
    );
}
@[Link("imm32")]
lib LibIMM32
  fun ImmGetHotKey = ImmGetHotKey(
    param0 : UInt32,   # DWORD
    lpuModifiers : UInt32*,   # DWORD* out
    lpuVKey : UInt32*,   # DWORD* out
    phKL : Void*   # HKL* out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef ImmGetHotKeyNative = Int32 Function(Uint32, Pointer<Uint32>, Pointer<Uint32>, Pointer<Void>);
typedef ImmGetHotKeyDart = int Function(int, Pointer<Uint32>, Pointer<Uint32>, Pointer<Void>);
final ImmGetHotKey = DynamicLibrary.open('IMM32.dll')
    .lookupFunction<ImmGetHotKeyNative, ImmGetHotKeyDart>('ImmGetHotKey');
// param0 : DWORD -> Uint32
// lpuModifiers : DWORD* out -> Pointer<Uint32>
// lpuVKey : DWORD* out -> Pointer<Uint32>
// phKL : HKL* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ImmGetHotKey(
  param0: DWORD;   // DWORD
  lpuModifiers: Pointer;   // DWORD* out
  lpuVKey: Pointer;   // DWORD* out
  phKL: Pointer   // HKL* out
): BOOL; stdcall;
  external 'IMM32.dll' name 'ImmGetHotKey';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "ImmGetHotKey"
  c_ImmGetHotKey :: Word32 -> Ptr Word32 -> Ptr Word32 -> Ptr () -> IO CInt
-- param0 : DWORD -> Word32
-- lpuModifiers : DWORD* out -> Ptr Word32
-- lpuVKey : DWORD* out -> Ptr Word32
-- phKL : HKL* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let immgethotkey =
  foreign "ImmGetHotKey"
    (uint32_t @-> (ptr uint32_t) @-> (ptr uint32_t) @-> (ptr void) @-> returning int32_t)
(* param0 : DWORD -> uint32_t *)
(* lpuModifiers : DWORD* out -> (ptr uint32_t) *)
(* lpuVKey : DWORD* out -> (ptr uint32_t) *)
(* phKL : HKL* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library imm32 (t "IMM32.dll"))
(cffi:use-foreign-library imm32)

(cffi:defcfun ("ImmGetHotKey" imm-get-hot-key :convention :stdcall) :int32
  (param0 :uint32)   ; DWORD
  (lpu-modifiers :pointer)   ; DWORD* out
  (lpu-vkey :pointer)   ; DWORD* out
  (ph-kl :pointer))   ; HKL* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ImmGetHotKey = Win32::API::More->new('IMM32',
    'BOOL ImmGetHotKey(DWORD param0, LPVOID lpuModifiers, LPVOID lpuVKey, HANDLE phKL)');
# my $ret = $ImmGetHotKey->Call($param0, $lpuModifiers, $lpuVKey, $phKL);
# param0 : DWORD -> DWORD
# lpuModifiers : DWORD* out -> LPVOID
# lpuVKey : DWORD* out -> LPVOID
# phKL : HKL* out -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。