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

GetWindowRegionData

関数
指定ウィンドウのリージョンデータを取得する。
DLLDCIMAN32.dll呼出規約winapi

シグネチャ

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

DWORD GetWindowRegionData(
    HWND hwnd,
    DWORD size,
    RGNDATA* prd
);

パラメーター

名前方向
hwndHWNDin
sizeDWORDin
prdRGNDATA*inout

戻り値の型: DWORD

各言語での呼び出し定義

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

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

GetWindowRegionData = ctypes.windll.dciman32.GetWindowRegionData
GetWindowRegionData.restype = wintypes.DWORD
GetWindowRegionData.argtypes = [
    wintypes.HANDLE,  # hwnd : HWND
    wintypes.DWORD,  # size : DWORD
    ctypes.c_void_p,  # prd : RGNDATA* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('DCIMAN32.dll')
GetWindowRegionData = Fiddle::Function.new(
  lib['GetWindowRegionData'],
  [
    Fiddle::TYPE_VOIDP,  # hwnd : HWND
    -Fiddle::TYPE_INT,  # size : DWORD
    Fiddle::TYPE_VOIDP,  # prd : RGNDATA* in/out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "dciman32")]
extern "system" {
    fn GetWindowRegionData(
        hwnd: *mut core::ffi::c_void,  // HWND
        size: u32,  // DWORD
        prd: *mut RGNDATA  // RGNDATA* in/out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("DCIMAN32.dll")]
public static extern uint GetWindowRegionData(IntPtr hwnd, uint size, IntPtr prd);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DCIMAN32_GetWindowRegionData' -Namespace Win32 -PassThru
# $api::GetWindowRegionData(hwnd, size, prd)
#uselib "DCIMAN32.dll"
#func global GetWindowRegionData "GetWindowRegionData" sptr, sptr, sptr
; GetWindowRegionData hwnd, size, varptr(prd)   ; 戻り値は stat
; hwnd : HWND -> "sptr"
; size : DWORD -> "sptr"
; prd : RGNDATA* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "DCIMAN32.dll"
#cfunc global GetWindowRegionData "GetWindowRegionData" sptr, int, var
; res = GetWindowRegionData(hwnd, size, prd)
; hwnd : HWND -> "sptr"
; size : DWORD -> "int"
; prd : RGNDATA* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD GetWindowRegionData(HWND hwnd, DWORD size, RGNDATA* prd)
#uselib "DCIMAN32.dll"
#cfunc global GetWindowRegionData "GetWindowRegionData" intptr, int, var
; res = GetWindowRegionData(hwnd, size, prd)
; hwnd : HWND -> "intptr"
; size : DWORD -> "int"
; prd : RGNDATA* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dciman32 = windows.NewLazySystemDLL("DCIMAN32.dll")
	procGetWindowRegionData = dciman32.NewProc("GetWindowRegionData")
)

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