Win32 API 日本語リファレンス
ホームSystem.WindowsProgramming › WinWatchNotify

WinWatchNotify

関数
ウィンドウ状態変化時の通知コールバックを登録する。
DLLDCIMAN32.dll呼出規約winapi

シグネチャ

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

BOOL WinWatchNotify(
    HWINWATCH hWW,
    WINWATCHNOTIFYPROC NotifyCallback,
    LPARAM NotifyParam
);

パラメーター

名前方向説明
hWWHWINWATCHin通知を設定する対象の監視ハンドル(HWINWATCH)。
NotifyCallbackWINWATCHNOTIFYPROCinウィンドウ変化時に呼び出される通知コールバック(WINWATCHNOTIFYPROC)。
NotifyParamLPARAMinコールバックに渡される呼び出し側定義のパラメーター。

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL WinWatchNotify(
    HWINWATCH hWW,
    WINWATCHNOTIFYPROC NotifyCallback,
    LPARAM NotifyParam
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("DCIMAN32.dll", ExactSpelling = true)]
static extern bool WinWatchNotify(
    IntPtr hWW,   // HWINWATCH
    IntPtr NotifyCallback,   // WINWATCHNOTIFYPROC
    IntPtr NotifyParam   // LPARAM
);
<DllImport("DCIMAN32.dll", ExactSpelling:=True)>
Public Shared Function WinWatchNotify(
    hWW As IntPtr,   ' HWINWATCH
    NotifyCallback As IntPtr,   ' WINWATCHNOTIFYPROC
    NotifyParam As IntPtr   ' LPARAM
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' hWW : HWINWATCH
' NotifyCallback : WINWATCHNOTIFYPROC
' NotifyParam : LPARAM
Declare PtrSafe Function WinWatchNotify Lib "dciman32" ( _
    ByVal hWW As LongPtr, _
    ByVal NotifyCallback As LongPtr, _
    ByVal NotifyParam As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WinWatchNotify = ctypes.windll.dciman32.WinWatchNotify
WinWatchNotify.restype = wintypes.BOOL
WinWatchNotify.argtypes = [
    wintypes.HANDLE,  # hWW : HWINWATCH
    ctypes.c_void_p,  # NotifyCallback : WINWATCHNOTIFYPROC
    ctypes.c_ssize_t,  # NotifyParam : LPARAM
]
require 'fiddle'
require 'fiddle/import'

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

var (
	dciman32 = windows.NewLazySystemDLL("DCIMAN32.dll")
	procWinWatchNotify = dciman32.NewProc("WinWatchNotify")
)

// hWW (HWINWATCH), NotifyCallback (WINWATCHNOTIFYPROC), NotifyParam (LPARAM)
r1, _, err := procWinWatchNotify.Call(
	uintptr(hWW),
	uintptr(NotifyCallback),
	uintptr(NotifyParam),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function WinWatchNotify(
  hWW: THandle;   // HWINWATCH
  NotifyCallback: Pointer;   // WINWATCHNOTIFYPROC
  NotifyParam: NativeInt   // LPARAM
): BOOL; stdcall;
  external 'DCIMAN32.dll' name 'WinWatchNotify';
result := DllCall("DCIMAN32\WinWatchNotify"
    , "Ptr", hWW   ; HWINWATCH
    , "Ptr", NotifyCallback   ; WINWATCHNOTIFYPROC
    , "Ptr", NotifyParam   ; LPARAM
    , "Int")   ; return: BOOL
●WinWatchNotify(hWW, NotifyCallback, NotifyParam) = DLL("DCIMAN32.dll", "bool WinWatchNotify(void*, void*, int)")
# 呼び出し: WinWatchNotify(hWW, NotifyCallback, NotifyParam)
# hWW : HWINWATCH -> "void*"
# NotifyCallback : WINWATCHNOTIFYPROC -> "void*"
# NotifyParam : LPARAM -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "dciman32" fn WinWatchNotify(
    hWW: ?*anyopaque, // HWINWATCH
    NotifyCallback: ?*anyopaque, // WINWATCHNOTIFYPROC
    NotifyParam: isize // LPARAM
) callconv(std.os.windows.WINAPI) i32;
proc WinWatchNotify(
    hWW: pointer,  # HWINWATCH
    NotifyCallback: pointer,  # WINWATCHNOTIFYPROC
    NotifyParam: int  # LPARAM
): int32 {.importc: "WinWatchNotify", stdcall, dynlib: "DCIMAN32.dll".}
pragma(lib, "dciman32");
extern(Windows)
int WinWatchNotify(
    void* hWW,   // HWINWATCH
    void* NotifyCallback,   // WINWATCHNOTIFYPROC
    ptrdiff_t NotifyParam   // LPARAM
);
ccall((:WinWatchNotify, "DCIMAN32.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{Cvoid}, Int),
      hWW, NotifyCallback, NotifyParam)
# hWW : HWINWATCH -> Ptr{Cvoid}
# NotifyCallback : WINWATCHNOTIFYPROC -> Ptr{Cvoid}
# NotifyParam : LPARAM -> Int
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t WinWatchNotify(
    void* hWW,
    void* NotifyCallback,
    intptr_t NotifyParam);
]]
local dciman32 = ffi.load("dciman32")
-- dciman32.WinWatchNotify(hWW, NotifyCallback, NotifyParam)
-- hWW : HWINWATCH
-- NotifyCallback : WINWATCHNOTIFYPROC
-- NotifyParam : LPARAM
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('DCIMAN32.dll');
const WinWatchNotify = lib.func('__stdcall', 'WinWatchNotify', 'int32_t', ['void *', 'void *', 'intptr_t']);
// WinWatchNotify(hWW, NotifyCallback, NotifyParam)
// hWW : HWINWATCH -> 'void *'
// NotifyCallback : WINWATCHNOTIFYPROC -> 'void *'
// NotifyParam : LPARAM -> 'intptr_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。
const lib = Deno.dlopen("DCIMAN32.dll", {
  WinWatchNotify: { parameters: ["pointer", "pointer", "isize"], result: "i32" },
});
// lib.symbols.WinWatchNotify(hWW, NotifyCallback, NotifyParam)
// hWW : HWINWATCH -> "pointer"
// NotifyCallback : WINWATCHNOTIFYPROC -> "pointer"
// NotifyParam : LPARAM -> "isize"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t WinWatchNotify(
    void* hWW,
    void* NotifyCallback,
    intptr_t NotifyParam);
C, "DCIMAN32.dll");
// $ffi->WinWatchNotify(hWW, NotifyCallback, NotifyParam);
// hWW : HWINWATCH
// NotifyCallback : WINWATCHNOTIFYPROC
// NotifyParam : LPARAM
// 構造体/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 Dciman32 extends StdCallLibrary {
    Dciman32 INSTANCE = Native.load("dciman32", Dciman32.class);
    boolean WinWatchNotify(
        Pointer hWW,   // HWINWATCH
        Callback NotifyCallback,   // WINWATCHNOTIFYPROC
        long NotifyParam   // LPARAM
    );
}
@[Link("dciman32")]
lib LibDCIMAN32
  fun WinWatchNotify = WinWatchNotify(
    hWW : Void*,   # HWINWATCH
    NotifyCallback : Void*,   # WINWATCHNOTIFYPROC
    NotifyParam : LibC::SSizeT   # LPARAM
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef WinWatchNotifyNative = Int32 Function(Pointer<Void>, Pointer<Void>, IntPtr);
typedef WinWatchNotifyDart = int Function(Pointer<Void>, Pointer<Void>, int);
final WinWatchNotify = DynamicLibrary.open('DCIMAN32.dll')
    .lookupFunction<WinWatchNotifyNative, WinWatchNotifyDart>('WinWatchNotify');
// hWW : HWINWATCH -> Pointer<Void>
// NotifyCallback : WINWATCHNOTIFYPROC -> Pointer<Void>
// NotifyParam : LPARAM -> IntPtr
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WinWatchNotify(
  hWW: THandle;   // HWINWATCH
  NotifyCallback: Pointer;   // WINWATCHNOTIFYPROC
  NotifyParam: NativeInt   // LPARAM
): BOOL; stdcall;
  external 'DCIMAN32.dll' name 'WinWatchNotify';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WinWatchNotify"
  c_WinWatchNotify :: Ptr () -> Ptr () -> CIntPtr -> IO CInt
-- hWW : HWINWATCH -> Ptr ()
-- NotifyCallback : WINWATCHNOTIFYPROC -> Ptr ()
-- NotifyParam : LPARAM -> CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let winwatchnotify =
  foreign "WinWatchNotify"
    ((ptr void) @-> (ptr void) @-> intptr_t @-> returning int32_t)
(* hWW : HWINWATCH -> (ptr void) *)
(* NotifyCallback : WINWATCHNOTIFYPROC -> (ptr void) *)
(* NotifyParam : LPARAM -> intptr_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library dciman32 (t "DCIMAN32.dll"))
(cffi:use-foreign-library dciman32)

(cffi:defcfun ("WinWatchNotify" win-watch-notify :convention :stdcall) :int32
  (h-ww :pointer)   ; HWINWATCH
  (notify-callback :pointer)   ; WINWATCHNOTIFYPROC
  (notify-param :int64))   ; LPARAM
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WinWatchNotify = Win32::API::More->new('DCIMAN32',
    'BOOL WinWatchNotify(HANDLE hWW, LPVOID NotifyCallback, LPARAM NotifyParam)');
# my $ret = $WinWatchNotify->Call($hWW, $NotifyCallback, $NotifyParam);
# hWW : HWINWATCH -> HANDLE
# NotifyCallback : WINWATCHNOTIFYPROC -> LPVOID
# NotifyParam : LPARAM -> LPARAM
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。

関連項目

使用する型