ホーム › UI.Input.Ime › ImmSetHotKey
ImmSetHotKey
関数IMEホットキーの修飾子・仮想キー・レイアウトを設定する。
シグネチャ
// IMM32.dll
#include <windows.h>
BOOL ImmSetHotKey(
DWORD param0,
DWORD param1,
DWORD param2,
HKL param3
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| param0 | DWORD | in | 設定対象のIMEホットキーID(IME_HOTKEY_*)。 |
| param1 | DWORD | in | ホットキーの修飾キー(MOD_*)。 |
| param2 | DWORD | in | ホットキーの仮想キーコード。 |
| param3 | HKL | in | ホットキーに関連付けるキーボードレイアウト(HKL)。 |
戻り値の型: 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 <MarshalAs(UnmanagedType.Bool)> 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 // BOOLfunction 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)。const std = @import("std");
extern "imm32" fn ImmSetHotKey(
param0: u32, // DWORD
param1: u32, // DWORD
param2: u32, // DWORD
param3: ?*anyopaque // HKL
) callconv(std.os.windows.WINAPI) i32;proc ImmSetHotKey(
param0: uint32, # DWORD
param1: uint32, # DWORD
param2: uint32, # DWORD
param3: pointer # HKL
): int32 {.importc: "ImmSetHotKey", stdcall, dynlib: "IMM32.dll".}pragma(lib, "imm32");
extern(Windows)
int ImmSetHotKey(
uint param0, // DWORD
uint param1, // DWORD
uint param2, // DWORD
void* param3 // HKL
);ccall((:ImmSetHotKey, "IMM32.dll"), stdcall, Int32,
(UInt32, UInt32, UInt32, Ptr{Cvoid}),
param0, param1, param2, param3)
# param0 : DWORD -> UInt32
# param1 : DWORD -> UInt32
# param2 : DWORD -> UInt32
# param3 : HKL -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t ImmSetHotKey(
uint32_t param0,
uint32_t param1,
uint32_t param2,
void* param3);
]]
local imm32 = ffi.load("imm32")
-- imm32.ImmSetHotKey(param0, param1, param2, param3)
-- param0 : DWORD
-- param1 : DWORD
-- param2 : DWORD
-- param3 : HKL
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('IMM32.dll');
const ImmSetHotKey = lib.func('__stdcall', 'ImmSetHotKey', 'int32_t', ['uint32_t', 'uint32_t', 'uint32_t', 'void *']);
// ImmSetHotKey(param0, param1, param2, param3)
// param0 : DWORD -> 'uint32_t'
// param1 : DWORD -> 'uint32_t'
// param2 : DWORD -> 'uint32_t'
// param3 : HKL -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("IMM32.dll", {
ImmSetHotKey: { parameters: ["u32", "u32", "u32", "pointer"], result: "i32" },
});
// lib.symbols.ImmSetHotKey(param0, param1, param2, param3)
// param0 : DWORD -> "u32"
// param1 : DWORD -> "u32"
// param2 : DWORD -> "u32"
// param3 : HKL -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t ImmSetHotKey(
uint32_t param0,
uint32_t param1,
uint32_t param2,
void* param3);
C, "IMM32.dll");
// $ffi->ImmSetHotKey(param0, param1, param2, param3);
// param0 : DWORD
// param1 : DWORD
// param2 : DWORD
// param3 : HKL
// 構造体/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 ImmSetHotKey(
int param0, // DWORD
int param1, // DWORD
int param2, // DWORD
Pointer param3 // HKL
);
}@[Link("imm32")]
lib LibIMM32
fun ImmSetHotKey = ImmSetHotKey(
param0 : UInt32, # DWORD
param1 : UInt32, # DWORD
param2 : UInt32, # DWORD
param3 : Void* # HKL
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ImmSetHotKeyNative = Int32 Function(Uint32, Uint32, Uint32, Pointer<Void>);
typedef ImmSetHotKeyDart = int Function(int, int, int, Pointer<Void>);
final ImmSetHotKey = DynamicLibrary.open('IMM32.dll')
.lookupFunction<ImmSetHotKeyNative, ImmSetHotKeyDart>('ImmSetHotKey');
// param0 : DWORD -> Uint32
// param1 : DWORD -> Uint32
// param2 : DWORD -> Uint32
// param3 : HKL -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ImmSetHotKey(
param0: DWORD; // DWORD
param1: DWORD; // DWORD
param2: DWORD; // DWORD
param3: THandle // HKL
): BOOL; stdcall;
external 'IMM32.dll' name 'ImmSetHotKey';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ImmSetHotKey"
c_ImmSetHotKey :: Word32 -> Word32 -> Word32 -> Ptr () -> IO CInt
-- param0 : DWORD -> Word32
-- param1 : DWORD -> Word32
-- param2 : DWORD -> Word32
-- param3 : HKL -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let immsethotkey =
foreign "ImmSetHotKey"
(uint32_t @-> uint32_t @-> uint32_t @-> (ptr void) @-> returning int32_t)
(* param0 : DWORD -> uint32_t *)
(* param1 : DWORD -> uint32_t *)
(* param2 : DWORD -> uint32_t *)
(* param3 : HKL -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library imm32 (t "IMM32.dll"))
(cffi:use-foreign-library imm32)
(cffi:defcfun ("ImmSetHotKey" imm-set-hot-key :convention :stdcall) :int32
(param0 :uint32) ; DWORD
(param1 :uint32) ; DWORD
(param2 :uint32) ; DWORD
(param3 :pointer)) ; HKL
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ImmSetHotKey = Win32::API::More->new('IMM32',
'BOOL ImmSetHotKey(DWORD param0, DWORD param1, DWORD param2, HANDLE param3)');
# my $ret = $ImmSetHotKey->Call($param0, $param1, $param2, $param3);
# param0 : DWORD -> DWORD
# param1 : DWORD -> DWORD
# param2 : DWORD -> DWORD
# param3 : HKL -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。