Win32 API 日本語リファレンス
ホームUI.WindowsAndMessaging › CallMsgFilterW

CallMsgFilterW

関数
メッセージフィルタフックを呼び出す(Unicode)。
DLLUSER32.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// USER32.dll  (Unicode / -W)
#include <windows.h>

BOOL CallMsgFilterW(
    MSG* lpMsg,
    INT nCode
);

パラメーター

名前方向
lpMsgMSG*in
nCodeINTin

戻り値の型: BOOL

各言語での呼び出し定義

// USER32.dll  (Unicode / -W)
#include <windows.h>

BOOL CallMsgFilterW(
    MSG* lpMsg,
    INT nCode
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern bool CallMsgFilterW(
    IntPtr lpMsg,   // MSG*
    int nCode   // INT
);
<DllImport("USER32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function CallMsgFilterW(
    lpMsg As IntPtr,   ' MSG*
    nCode As Integer   ' INT
) As Boolean
End Function
' lpMsg : MSG*
' nCode : INT
Declare PtrSafe Function CallMsgFilterW Lib "user32" ( _
    ByVal lpMsg As LongPtr, _
    ByVal nCode As Long) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CallMsgFilterW = ctypes.windll.user32.CallMsgFilterW
CallMsgFilterW.restype = wintypes.BOOL
CallMsgFilterW.argtypes = [
    ctypes.c_void_p,  # lpMsg : MSG*
    ctypes.c_int,  # nCode : INT
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
CallMsgFilterW = Fiddle::Function.new(
  lib['CallMsgFilterW'],
  [
    Fiddle::TYPE_VOIDP,  # lpMsg : MSG*
    Fiddle::TYPE_INT,  # nCode : INT
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "user32")]
extern "system" {
    fn CallMsgFilterW(
        lpMsg: *mut MSG,  // MSG*
        nCode: i32  // INT
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", CharSet = CharSet.Unicode)]
public static extern bool CallMsgFilterW(IntPtr lpMsg, int nCode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_CallMsgFilterW' -Namespace Win32 -PassThru
# $api::CallMsgFilterW(lpMsg, nCode)
#uselib "USER32.dll"
#func global CallMsgFilterW "CallMsgFilterW" wptr, wptr
; CallMsgFilterW varptr(lpMsg), nCode   ; 戻り値は stat
; lpMsg : MSG* -> "wptr"
; nCode : INT -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "USER32.dll"
#cfunc global CallMsgFilterW "CallMsgFilterW" var, int
; res = CallMsgFilterW(lpMsg, nCode)
; lpMsg : MSG* -> "var"
; nCode : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL CallMsgFilterW(MSG* lpMsg, INT nCode)
#uselib "USER32.dll"
#cfunc global CallMsgFilterW "CallMsgFilterW" var, int
; res = CallMsgFilterW(lpMsg, nCode)
; lpMsg : MSG* -> "var"
; nCode : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procCallMsgFilterW = user32.NewProc("CallMsgFilterW")
)

// lpMsg (MSG*), nCode (INT)
r1, _, err := procCallMsgFilterW.Call(
	uintptr(lpMsg),
	uintptr(nCode),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function CallMsgFilterW(
  lpMsg: Pointer;   // MSG*
  nCode: Integer   // INT
): BOOL; stdcall;
  external 'USER32.dll' name 'CallMsgFilterW';
result := DllCall("USER32\CallMsgFilterW"
    , "Ptr", lpMsg   ; MSG*
    , "Int", nCode   ; INT
    , "Int")   ; return: BOOL
●CallMsgFilterW(lpMsg, nCode) = DLL("USER32.dll", "bool CallMsgFilterW(void*, int)")
# 呼び出し: CallMsgFilterW(lpMsg, nCode)
# lpMsg : MSG* -> "void*"
# nCode : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。