ホーム › System.WindowsProgramming › GetDCRegionData
GetDCRegionData
関数デバイスコンテキストのリージョンデータを取得する。
シグネチャ
// DCIMAN32.dll
#include <windows.h>
DWORD GetDCRegionData(
HDC hdc,
DWORD size,
RGNDATA* prd
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hdc | HDC | in | 領域データを取得する対象のデバイスコンテキストハンドル。 |
| size | DWORD | in | prdバッファのサイズをバイト単位で指定する。 |
| prd | RGNDATA* | inout | DCのクリップ領域データを受け取るRGNDATA構造体へのポインタ。 |
戻り値の型: 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 方式にも切替可。#uselib "DCIMAN32.dll" #cfunc global GetDCRegionData "GetDCRegionData" sptr, int, sptr ; res = GetDCRegionData(hdc, size, varptr(prd)) ; hdc : HDC -> "sptr" ; size : DWORD -> "int" ; prd : RGNDATA* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; DWORD GetDCRegionData(HDC hdc, DWORD size, RGNDATA* prd) #uselib "DCIMAN32.dll" #cfunc global GetDCRegionData "GetDCRegionData" intptr, int, intptr ; res = GetDCRegionData(hdc, size, varptr(prd)) ; hdc : HDC -> "intptr" ; size : DWORD -> "int" ; prd : RGNDATA* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // DWORDfunction 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)。const std = @import("std");
extern "dciman32" fn GetDCRegionData(
hdc: ?*anyopaque, // HDC
size: u32, // DWORD
prd: [*c]RGNDATA // RGNDATA* in/out
) callconv(std.os.windows.WINAPI) u32;proc GetDCRegionData(
hdc: pointer, # HDC
size: uint32, # DWORD
prd: ptr RGNDATA # RGNDATA* in/out
): uint32 {.importc: "GetDCRegionData", stdcall, dynlib: "DCIMAN32.dll".}pragma(lib, "dciman32");
extern(Windows)
uint GetDCRegionData(
void* hdc, // HDC
uint size, // DWORD
RGNDATA* prd // RGNDATA* in/out
);ccall((:GetDCRegionData, "DCIMAN32.dll"), stdcall, UInt32,
(Ptr{Cvoid}, UInt32, Ptr{RGNDATA}),
hdc, size, prd)
# hdc : HDC -> Ptr{Cvoid}
# size : DWORD -> UInt32
# prd : RGNDATA* in/out -> Ptr{RGNDATA}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t GetDCRegionData(
void* hdc,
uint32_t size,
void* prd);
]]
local dciman32 = ffi.load("dciman32")
-- dciman32.GetDCRegionData(hdc, size, prd)
-- hdc : HDC
-- size : DWORD
-- prd : RGNDATA* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('DCIMAN32.dll');
const GetDCRegionData = lib.func('__stdcall', 'GetDCRegionData', 'uint32_t', ['void *', 'uint32_t', 'void *']);
// GetDCRegionData(hdc, size, prd)
// hdc : HDC -> 'void *'
// size : DWORD -> 'uint32_t'
// prd : RGNDATA* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("DCIMAN32.dll", {
GetDCRegionData: { parameters: ["pointer", "u32", "pointer"], result: "u32" },
});
// lib.symbols.GetDCRegionData(hdc, size, prd)
// hdc : HDC -> "pointer"
// size : DWORD -> "u32"
// prd : RGNDATA* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t GetDCRegionData(
void* hdc,
uint32_t size,
void* prd);
C, "DCIMAN32.dll");
// $ffi->GetDCRegionData(hdc, size, prd);
// hdc : HDC
// size : DWORD
// prd : RGNDATA* in/out
// 構造体/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);
int GetDCRegionData(
Pointer hdc, // HDC
int size, // DWORD
Pointer prd // RGNDATA* in/out
);
}@[Link("dciman32")]
lib LibDCIMAN32
fun GetDCRegionData = GetDCRegionData(
hdc : Void*, # HDC
size : UInt32, # DWORD
prd : RGNDATA* # RGNDATA* in/out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GetDCRegionDataNative = Uint32 Function(Pointer<Void>, Uint32, Pointer<Void>);
typedef GetDCRegionDataDart = int Function(Pointer<Void>, int, Pointer<Void>);
final GetDCRegionData = DynamicLibrary.open('DCIMAN32.dll')
.lookupFunction<GetDCRegionDataNative, GetDCRegionDataDart>('GetDCRegionData');
// hdc : HDC -> Pointer<Void>
// size : DWORD -> Uint32
// prd : RGNDATA* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GetDCRegionData(
hdc: THandle; // HDC
size: DWORD; // DWORD
prd: Pointer // RGNDATA* in/out
): DWORD; stdcall;
external 'DCIMAN32.dll' name 'GetDCRegionData';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GetDCRegionData"
c_GetDCRegionData :: Ptr () -> Word32 -> Ptr () -> IO Word32
-- hdc : HDC -> Ptr ()
-- size : DWORD -> Word32
-- prd : RGNDATA* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let getdcregiondata =
foreign "GetDCRegionData"
((ptr void) @-> uint32_t @-> (ptr void) @-> returning uint32_t)
(* hdc : HDC -> (ptr void) *)
(* size : DWORD -> uint32_t *)
(* prd : RGNDATA* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library dciman32 (t "DCIMAN32.dll"))
(cffi:use-foreign-library dciman32)
(cffi:defcfun ("GetDCRegionData" get-dcregion-data :convention :stdcall) :uint32
(hdc :pointer) ; HDC
(size :uint32) ; DWORD
(prd :pointer)) ; RGNDATA* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GetDCRegionData = Win32::API::More->new('DCIMAN32',
'DWORD GetDCRegionData(HANDLE hdc, DWORD size, LPVOID prd)');
# my $ret = $GetDCRegionData->Call($hdc, $size, $prd);
# hdc : HDC -> HANDLE
# size : DWORD -> DWORD
# prd : RGNDATA* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型