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

GetDCRegionData

関数
デバイスコンテキストのリージョンデータを取得する。
DLLDCIMAN32.dll呼出規約winapi

シグネチャ

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

DWORD GetDCRegionData(
    HDC hdc,
    DWORD size,
    RGNDATA* prd
);

パラメーター

名前方向
hdcHDCin
sizeDWORDin
prdRGNDATA*inout

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD GetDCRegionData(
    HDC hdc,
    DWORD size,
    RGNDATA* prd
);
[DllImport("DCIMAN32.dll", ExactSpelling = true)]
static extern uint GetDCRegionData(
    IntPtr hdc,   // HDC
    uint size,   // DWORD
    IntPtr prd   // RGNDATA* in/out
);
<DllImport("DCIMAN32.dll", ExactSpelling:=True)>
Public Shared Function GetDCRegionData(
    hdc As IntPtr,   ' HDC
    size As UInteger,   ' DWORD
    prd As IntPtr   ' RGNDATA* in/out
) As UInteger
End Function
' hdc : HDC
' size : DWORD
' prd : RGNDATA* in/out
Declare PtrSafe Function GetDCRegionData Lib "dciman32" ( _
    ByVal hdc 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

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

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

var (
	dciman32 = windows.NewLazySystemDLL("DCIMAN32.dll")
	procGetDCRegionData = dciman32.NewProc("GetDCRegionData")
)

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