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

InheritWindowMonitor

関数
ウィンドウの表示モニタを別ウィンドウから継承させる。
DLLUSER32.dll呼出規約winapi

シグネチャ

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

BOOL InheritWindowMonitor(
    HWND hwnd,
    HWND hwndInherit   // optional
);

パラメーター

名前方向説明
hwndHWNDinモニタ割り当てを継承する対象ウィンドウのハンドル。
hwndInheritHWNDinoptionalモニタ情報の継承元となるウィンドウのハンドル。NULL可。

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL InheritWindowMonitor(
    HWND hwnd,
    HWND hwndInherit   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", ExactSpelling = true)]
static extern bool InheritWindowMonitor(
    IntPtr hwnd,   // HWND
    IntPtr hwndInherit   // HWND optional
);
<DllImport("USER32.dll", ExactSpelling:=True)>
Public Shared Function InheritWindowMonitor(
    hwnd As IntPtr,   ' HWND
    hwndInherit As IntPtr   ' HWND optional
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' hwnd : HWND
' hwndInherit : HWND optional
Declare PtrSafe Function InheritWindowMonitor Lib "user32" ( _
    ByVal hwnd As LongPtr, _
    ByVal hwndInherit As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

InheritWindowMonitor = ctypes.windll.user32.InheritWindowMonitor
InheritWindowMonitor.restype = wintypes.BOOL
InheritWindowMonitor.argtypes = [
    wintypes.HANDLE,  # hwnd : HWND
    wintypes.HANDLE,  # hwndInherit : HWND optional
]
require 'fiddle'
require 'fiddle/import'

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

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procInheritWindowMonitor = user32.NewProc("InheritWindowMonitor")
)

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

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

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

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

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

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