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

WinWatchOpen

関数
指定ウィンドウの状態監視ハンドルを開く。
DLLDCIMAN32.dll呼出規約winapi

シグネチャ

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

HWINWATCH WinWatchOpen(
    HWND hwnd
);

パラメーター

名前方向説明
hwndHWNDin監視を開始する対象ウィンドウのハンドル。

戻り値の型: HWINWATCH

各言語での呼び出し定義

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

HWINWATCH WinWatchOpen(
    HWND hwnd
);
[DllImport("DCIMAN32.dll", ExactSpelling = true)]
static extern IntPtr WinWatchOpen(
    IntPtr hwnd   // HWND
);
<DllImport("DCIMAN32.dll", ExactSpelling:=True)>
Public Shared Function WinWatchOpen(
    hwnd As IntPtr   ' HWND
) As IntPtr
End Function
' hwnd : HWND
Declare PtrSafe Function WinWatchOpen Lib "dciman32" ( _
    ByVal hwnd As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WinWatchOpen = ctypes.windll.dciman32.WinWatchOpen
WinWatchOpen.restype = ctypes.c_void_p
WinWatchOpen.argtypes = [
    wintypes.HANDLE,  # hwnd : HWND
]
require 'fiddle'
require 'fiddle/import'

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

var (
	dciman32 = windows.NewLazySystemDLL("DCIMAN32.dll")
	procWinWatchOpen = dciman32.NewProc("WinWatchOpen")
)

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

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

typedef WinWatchOpenNative = Pointer<Void> Function(Pointer<Void>);
typedef WinWatchOpenDart = Pointer<Void> Function(Pointer<Void>);
final WinWatchOpen = DynamicLibrary.open('DCIMAN32.dll')
    .lookupFunction<WinWatchOpenNative, WinWatchOpenDart>('WinWatchOpen');
// hwnd : HWND -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WinWatchOpen(
  hwnd: THandle   // HWND
): THandle; stdcall;
  external 'DCIMAN32.dll' name 'WinWatchOpen';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WinWatchOpen"
  c_WinWatchOpen :: Ptr () -> IO (Ptr ())
-- hwnd : HWND -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let winwatchopen =
  foreign "WinWatchOpen"
    ((ptr void) @-> returning (ptr void))
(* hwnd : HWND -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library dciman32 (t "DCIMAN32.dll"))
(cffi:use-foreign-library dciman32)

(cffi:defcfun ("WinWatchOpen" win-watch-open :convention :stdcall) :pointer
  (hwnd :pointer))   ; HWND
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WinWatchOpen = Win32::API::More->new('DCIMAN32',
    'HANDLE WinWatchOpen(HANDLE hwnd)');
# my $ret = $WinWatchOpen->Call($hwnd);
# hwnd : HWND -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。