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

ImmSetHotKey

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

シグネチャ

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

BOOL ImmSetHotKey(
    DWORD param0,
    DWORD param1,
    DWORD param2,
    HKL param3
);

パラメーター

名前方向
param0DWORDin
param1DWORDin
param2DWORDin
param3HKLin

戻り値の型: BOOL

各言語での呼び出し定義

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

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

ImmSetHotKey = ctypes.windll.imm32.ImmSetHotKey
ImmSetHotKey.restype = wintypes.BOOL
ImmSetHotKey.argtypes = [
    wintypes.DWORD,  # param0 : DWORD
    wintypes.DWORD,  # param1 : DWORD
    wintypes.DWORD,  # param2 : DWORD
    wintypes.HANDLE,  # param3 : HKL
]
require 'fiddle'
require 'fiddle/import'

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

var (
	imm32 = windows.NewLazySystemDLL("IMM32.dll")
	procImmSetHotKey = imm32.NewProc("ImmSetHotKey")
)

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