ホーム › System.WindowsProgramming › DCICreateOffscreen
DCICreateOffscreen
関数オフスクリーン描画サーフェスを作成する。
シグネチャ
// DCIMAN32.dll
#include <windows.h>
INT DCICreateOffscreen(
HDC hdc,
DWORD dwCompression,
DWORD dwRedMask,
DWORD dwGreenMask,
DWORD dwBlueMask,
DWORD dwWidth,
DWORD dwHeight,
DWORD dwDCICaps,
DWORD dwBitCount,
DCIOFFSCREEN** lplpSurface
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hdc | HDC | in | オフスクリーンサーフェスを作成する対象のデバイスコンテキストハンドル。 |
| dwCompression | DWORD | in | サーフェスの圧縮形式またはFourCCコードを指定する。 |
| dwRedMask | DWORD | in | 赤成分を表すビットマスク。 |
| dwGreenMask | DWORD | in | 緑成分を表すビットマスク。 |
| dwBlueMask | DWORD | in | 青成分を表すビットマスク。 |
| dwWidth | DWORD | in | サーフェスの幅をピクセル単位で指定する。 |
| dwHeight | DWORD | in | サーフェスの高さをピクセル単位で指定する。 |
| dwDCICaps | DWORD | in | 要求するDCIケイパビリティを表すフラグ。 |
| dwBitCount | DWORD | in | 1ピクセルあたりのビット数を指定する。 |
| lplpSurface | DCIOFFSCREEN** | inout | 作成されたオフスクリーンサーフェス(DCIOFFSCREEN)へのポインタを受け取る変数のアドレス。 |
戻り値の型: INT
各言語での呼び出し定義
// DCIMAN32.dll
#include <windows.h>
INT DCICreateOffscreen(
HDC hdc,
DWORD dwCompression,
DWORD dwRedMask,
DWORD dwGreenMask,
DWORD dwBlueMask,
DWORD dwWidth,
DWORD dwHeight,
DWORD dwDCICaps,
DWORD dwBitCount,
DCIOFFSCREEN** lplpSurface
);[DllImport("DCIMAN32.dll", ExactSpelling = true)]
static extern int DCICreateOffscreen(
IntPtr hdc, // HDC
uint dwCompression, // DWORD
uint dwRedMask, // DWORD
uint dwGreenMask, // DWORD
uint dwBlueMask, // DWORD
uint dwWidth, // DWORD
uint dwHeight, // DWORD
uint dwDCICaps, // DWORD
uint dwBitCount, // DWORD
IntPtr lplpSurface // DCIOFFSCREEN** in/out
);<DllImport("DCIMAN32.dll", ExactSpelling:=True)>
Public Shared Function DCICreateOffscreen(
hdc As IntPtr, ' HDC
dwCompression As UInteger, ' DWORD
dwRedMask As UInteger, ' DWORD
dwGreenMask As UInteger, ' DWORD
dwBlueMask As UInteger, ' DWORD
dwWidth As UInteger, ' DWORD
dwHeight As UInteger, ' DWORD
dwDCICaps As UInteger, ' DWORD
dwBitCount As UInteger, ' DWORD
lplpSurface As IntPtr ' DCIOFFSCREEN** in/out
) As Integer
End Function' hdc : HDC
' dwCompression : DWORD
' dwRedMask : DWORD
' dwGreenMask : DWORD
' dwBlueMask : DWORD
' dwWidth : DWORD
' dwHeight : DWORD
' dwDCICaps : DWORD
' dwBitCount : DWORD
' lplpSurface : DCIOFFSCREEN** in/out
Declare PtrSafe Function DCICreateOffscreen Lib "dciman32" ( _
ByVal hdc As LongPtr, _
ByVal dwCompression As Long, _
ByVal dwRedMask As Long, _
ByVal dwGreenMask As Long, _
ByVal dwBlueMask As Long, _
ByVal dwWidth As Long, _
ByVal dwHeight As Long, _
ByVal dwDCICaps As Long, _
ByVal dwBitCount As Long, _
ByVal lplpSurface As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DCICreateOffscreen = ctypes.windll.dciman32.DCICreateOffscreen
DCICreateOffscreen.restype = ctypes.c_int
DCICreateOffscreen.argtypes = [
wintypes.HANDLE, # hdc : HDC
wintypes.DWORD, # dwCompression : DWORD
wintypes.DWORD, # dwRedMask : DWORD
wintypes.DWORD, # dwGreenMask : DWORD
wintypes.DWORD, # dwBlueMask : DWORD
wintypes.DWORD, # dwWidth : DWORD
wintypes.DWORD, # dwHeight : DWORD
wintypes.DWORD, # dwDCICaps : DWORD
wintypes.DWORD, # dwBitCount : DWORD
ctypes.c_void_p, # lplpSurface : DCIOFFSCREEN** in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('DCIMAN32.dll')
DCICreateOffscreen = Fiddle::Function.new(
lib['DCICreateOffscreen'],
[
Fiddle::TYPE_VOIDP, # hdc : HDC
-Fiddle::TYPE_INT, # dwCompression : DWORD
-Fiddle::TYPE_INT, # dwRedMask : DWORD
-Fiddle::TYPE_INT, # dwGreenMask : DWORD
-Fiddle::TYPE_INT, # dwBlueMask : DWORD
-Fiddle::TYPE_INT, # dwWidth : DWORD
-Fiddle::TYPE_INT, # dwHeight : DWORD
-Fiddle::TYPE_INT, # dwDCICaps : DWORD
-Fiddle::TYPE_INT, # dwBitCount : DWORD
Fiddle::TYPE_VOIDP, # lplpSurface : DCIOFFSCREEN** in/out
],
Fiddle::TYPE_INT)#[link(name = "dciman32")]
extern "system" {
fn DCICreateOffscreen(
hdc: *mut core::ffi::c_void, // HDC
dwCompression: u32, // DWORD
dwRedMask: u32, // DWORD
dwGreenMask: u32, // DWORD
dwBlueMask: u32, // DWORD
dwWidth: u32, // DWORD
dwHeight: u32, // DWORD
dwDCICaps: u32, // DWORD
dwBitCount: u32, // DWORD
lplpSurface: *mut *mut DCIOFFSCREEN // DCIOFFSCREEN** in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("DCIMAN32.dll")]
public static extern int DCICreateOffscreen(IntPtr hdc, uint dwCompression, uint dwRedMask, uint dwGreenMask, uint dwBlueMask, uint dwWidth, uint dwHeight, uint dwDCICaps, uint dwBitCount, IntPtr lplpSurface);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DCIMAN32_DCICreateOffscreen' -Namespace Win32 -PassThru
# $api::DCICreateOffscreen(hdc, dwCompression, dwRedMask, dwGreenMask, dwBlueMask, dwWidth, dwHeight, dwDCICaps, dwBitCount, lplpSurface)#uselib "DCIMAN32.dll"
#func global DCICreateOffscreen "DCICreateOffscreen" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; DCICreateOffscreen hdc, dwCompression, dwRedMask, dwGreenMask, dwBlueMask, dwWidth, dwHeight, dwDCICaps, dwBitCount, varptr(lplpSurface) ; 戻り値は stat
; hdc : HDC -> "sptr"
; dwCompression : DWORD -> "sptr"
; dwRedMask : DWORD -> "sptr"
; dwGreenMask : DWORD -> "sptr"
; dwBlueMask : DWORD -> "sptr"
; dwWidth : DWORD -> "sptr"
; dwHeight : DWORD -> "sptr"
; dwDCICaps : DWORD -> "sptr"
; dwBitCount : DWORD -> "sptr"
; lplpSurface : DCIOFFSCREEN** in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "DCIMAN32.dll" #cfunc global DCICreateOffscreen "DCICreateOffscreen" sptr, int, int, int, int, int, int, int, int, var ; res = DCICreateOffscreen(hdc, dwCompression, dwRedMask, dwGreenMask, dwBlueMask, dwWidth, dwHeight, dwDCICaps, dwBitCount, lplpSurface) ; hdc : HDC -> "sptr" ; dwCompression : DWORD -> "int" ; dwRedMask : DWORD -> "int" ; dwGreenMask : DWORD -> "int" ; dwBlueMask : DWORD -> "int" ; dwWidth : DWORD -> "int" ; dwHeight : DWORD -> "int" ; dwDCICaps : DWORD -> "int" ; dwBitCount : DWORD -> "int" ; lplpSurface : DCIOFFSCREEN** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "DCIMAN32.dll" #cfunc global DCICreateOffscreen "DCICreateOffscreen" sptr, int, int, int, int, int, int, int, int, sptr ; res = DCICreateOffscreen(hdc, dwCompression, dwRedMask, dwGreenMask, dwBlueMask, dwWidth, dwHeight, dwDCICaps, dwBitCount, varptr(lplpSurface)) ; hdc : HDC -> "sptr" ; dwCompression : DWORD -> "int" ; dwRedMask : DWORD -> "int" ; dwGreenMask : DWORD -> "int" ; dwBlueMask : DWORD -> "int" ; dwWidth : DWORD -> "int" ; dwHeight : DWORD -> "int" ; dwDCICaps : DWORD -> "int" ; dwBitCount : DWORD -> "int" ; lplpSurface : DCIOFFSCREEN** in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT DCICreateOffscreen(HDC hdc, DWORD dwCompression, DWORD dwRedMask, DWORD dwGreenMask, DWORD dwBlueMask, DWORD dwWidth, DWORD dwHeight, DWORD dwDCICaps, DWORD dwBitCount, DCIOFFSCREEN** lplpSurface) #uselib "DCIMAN32.dll" #cfunc global DCICreateOffscreen "DCICreateOffscreen" intptr, int, int, int, int, int, int, int, int, var ; res = DCICreateOffscreen(hdc, dwCompression, dwRedMask, dwGreenMask, dwBlueMask, dwWidth, dwHeight, dwDCICaps, dwBitCount, lplpSurface) ; hdc : HDC -> "intptr" ; dwCompression : DWORD -> "int" ; dwRedMask : DWORD -> "int" ; dwGreenMask : DWORD -> "int" ; dwBlueMask : DWORD -> "int" ; dwWidth : DWORD -> "int" ; dwHeight : DWORD -> "int" ; dwDCICaps : DWORD -> "int" ; dwBitCount : DWORD -> "int" ; lplpSurface : DCIOFFSCREEN** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT DCICreateOffscreen(HDC hdc, DWORD dwCompression, DWORD dwRedMask, DWORD dwGreenMask, DWORD dwBlueMask, DWORD dwWidth, DWORD dwHeight, DWORD dwDCICaps, DWORD dwBitCount, DCIOFFSCREEN** lplpSurface) #uselib "DCIMAN32.dll" #cfunc global DCICreateOffscreen "DCICreateOffscreen" intptr, int, int, int, int, int, int, int, int, intptr ; res = DCICreateOffscreen(hdc, dwCompression, dwRedMask, dwGreenMask, dwBlueMask, dwWidth, dwHeight, dwDCICaps, dwBitCount, varptr(lplpSurface)) ; hdc : HDC -> "intptr" ; dwCompression : DWORD -> "int" ; dwRedMask : DWORD -> "int" ; dwGreenMask : DWORD -> "int" ; dwBlueMask : DWORD -> "int" ; dwWidth : DWORD -> "int" ; dwHeight : DWORD -> "int" ; dwDCICaps : DWORD -> "int" ; dwBitCount : DWORD -> "int" ; lplpSurface : DCIOFFSCREEN** in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
dciman32 = windows.NewLazySystemDLL("DCIMAN32.dll")
procDCICreateOffscreen = dciman32.NewProc("DCICreateOffscreen")
)
// hdc (HDC), dwCompression (DWORD), dwRedMask (DWORD), dwGreenMask (DWORD), dwBlueMask (DWORD), dwWidth (DWORD), dwHeight (DWORD), dwDCICaps (DWORD), dwBitCount (DWORD), lplpSurface (DCIOFFSCREEN** in/out)
r1, _, err := procDCICreateOffscreen.Call(
uintptr(hdc),
uintptr(dwCompression),
uintptr(dwRedMask),
uintptr(dwGreenMask),
uintptr(dwBlueMask),
uintptr(dwWidth),
uintptr(dwHeight),
uintptr(dwDCICaps),
uintptr(dwBitCount),
uintptr(lplpSurface),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction DCICreateOffscreen(
hdc: THandle; // HDC
dwCompression: DWORD; // DWORD
dwRedMask: DWORD; // DWORD
dwGreenMask: DWORD; // DWORD
dwBlueMask: DWORD; // DWORD
dwWidth: DWORD; // DWORD
dwHeight: DWORD; // DWORD
dwDCICaps: DWORD; // DWORD
dwBitCount: DWORD; // DWORD
lplpSurface: Pointer // DCIOFFSCREEN** in/out
): Integer; stdcall;
external 'DCIMAN32.dll' name 'DCICreateOffscreen';result := DllCall("DCIMAN32\DCICreateOffscreen"
, "Ptr", hdc ; HDC
, "UInt", dwCompression ; DWORD
, "UInt", dwRedMask ; DWORD
, "UInt", dwGreenMask ; DWORD
, "UInt", dwBlueMask ; DWORD
, "UInt", dwWidth ; DWORD
, "UInt", dwHeight ; DWORD
, "UInt", dwDCICaps ; DWORD
, "UInt", dwBitCount ; DWORD
, "Ptr", lplpSurface ; DCIOFFSCREEN** in/out
, "Int") ; return: INT●DCICreateOffscreen(hdc, dwCompression, dwRedMask, dwGreenMask, dwBlueMask, dwWidth, dwHeight, dwDCICaps, dwBitCount, lplpSurface) = DLL("DCIMAN32.dll", "int DCICreateOffscreen(void*, dword, dword, dword, dword, dword, dword, dword, dword, void*)")
# 呼び出し: DCICreateOffscreen(hdc, dwCompression, dwRedMask, dwGreenMask, dwBlueMask, dwWidth, dwHeight, dwDCICaps, dwBitCount, lplpSurface)
# hdc : HDC -> "void*"
# dwCompression : DWORD -> "dword"
# dwRedMask : DWORD -> "dword"
# dwGreenMask : DWORD -> "dword"
# dwBlueMask : DWORD -> "dword"
# dwWidth : DWORD -> "dword"
# dwHeight : DWORD -> "dword"
# dwDCICaps : DWORD -> "dword"
# dwBitCount : DWORD -> "dword"
# lplpSurface : DCIOFFSCREEN** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "dciman32" fn DCICreateOffscreen(
hdc: ?*anyopaque, // HDC
dwCompression: u32, // DWORD
dwRedMask: u32, // DWORD
dwGreenMask: u32, // DWORD
dwBlueMask: u32, // DWORD
dwWidth: u32, // DWORD
dwHeight: u32, // DWORD
dwDCICaps: u32, // DWORD
dwBitCount: u32, // DWORD
lplpSurface: [*c][*c]DCIOFFSCREEN // DCIOFFSCREEN** in/out
) callconv(std.os.windows.WINAPI) i32;proc DCICreateOffscreen(
hdc: pointer, # HDC
dwCompression: uint32, # DWORD
dwRedMask: uint32, # DWORD
dwGreenMask: uint32, # DWORD
dwBlueMask: uint32, # DWORD
dwWidth: uint32, # DWORD
dwHeight: uint32, # DWORD
dwDCICaps: uint32, # DWORD
dwBitCount: uint32, # DWORD
lplpSurface: ptr DCIOFFSCREEN # DCIOFFSCREEN** in/out
): int32 {.importc: "DCICreateOffscreen", stdcall, dynlib: "DCIMAN32.dll".}pragma(lib, "dciman32");
extern(Windows)
int DCICreateOffscreen(
void* hdc, // HDC
uint dwCompression, // DWORD
uint dwRedMask, // DWORD
uint dwGreenMask, // DWORD
uint dwBlueMask, // DWORD
uint dwWidth, // DWORD
uint dwHeight, // DWORD
uint dwDCICaps, // DWORD
uint dwBitCount, // DWORD
DCIOFFSCREEN** lplpSurface // DCIOFFSCREEN** in/out
);ccall((:DCICreateOffscreen, "DCIMAN32.dll"), stdcall, Int32,
(Ptr{Cvoid}, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, Ptr{DCIOFFSCREEN}),
hdc, dwCompression, dwRedMask, dwGreenMask, dwBlueMask, dwWidth, dwHeight, dwDCICaps, dwBitCount, lplpSurface)
# hdc : HDC -> Ptr{Cvoid}
# dwCompression : DWORD -> UInt32
# dwRedMask : DWORD -> UInt32
# dwGreenMask : DWORD -> UInt32
# dwBlueMask : DWORD -> UInt32
# dwWidth : DWORD -> UInt32
# dwHeight : DWORD -> UInt32
# dwDCICaps : DWORD -> UInt32
# dwBitCount : DWORD -> UInt32
# lplpSurface : DCIOFFSCREEN** in/out -> Ptr{DCIOFFSCREEN}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t DCICreateOffscreen(
void* hdc,
uint32_t dwCompression,
uint32_t dwRedMask,
uint32_t dwGreenMask,
uint32_t dwBlueMask,
uint32_t dwWidth,
uint32_t dwHeight,
uint32_t dwDCICaps,
uint32_t dwBitCount,
void* lplpSurface);
]]
local dciman32 = ffi.load("dciman32")
-- dciman32.DCICreateOffscreen(hdc, dwCompression, dwRedMask, dwGreenMask, dwBlueMask, dwWidth, dwHeight, dwDCICaps, dwBitCount, lplpSurface)
-- hdc : HDC
-- dwCompression : DWORD
-- dwRedMask : DWORD
-- dwGreenMask : DWORD
-- dwBlueMask : DWORD
-- dwWidth : DWORD
-- dwHeight : DWORD
-- dwDCICaps : DWORD
-- dwBitCount : DWORD
-- lplpSurface : DCIOFFSCREEN** in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('DCIMAN32.dll');
const DCICreateOffscreen = lib.func('__stdcall', 'DCICreateOffscreen', 'int32_t', ['void *', 'uint32_t', 'uint32_t', 'uint32_t', 'uint32_t', 'uint32_t', 'uint32_t', 'uint32_t', 'uint32_t', 'void *']);
// DCICreateOffscreen(hdc, dwCompression, dwRedMask, dwGreenMask, dwBlueMask, dwWidth, dwHeight, dwDCICaps, dwBitCount, lplpSurface)
// hdc : HDC -> 'void *'
// dwCompression : DWORD -> 'uint32_t'
// dwRedMask : DWORD -> 'uint32_t'
// dwGreenMask : DWORD -> 'uint32_t'
// dwBlueMask : DWORD -> 'uint32_t'
// dwWidth : DWORD -> 'uint32_t'
// dwHeight : DWORD -> 'uint32_t'
// dwDCICaps : DWORD -> 'uint32_t'
// dwBitCount : DWORD -> 'uint32_t'
// lplpSurface : DCIOFFSCREEN** in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("DCIMAN32.dll", {
DCICreateOffscreen: { parameters: ["pointer", "u32", "u32", "u32", "u32", "u32", "u32", "u32", "u32", "pointer"], result: "i32" },
});
// lib.symbols.DCICreateOffscreen(hdc, dwCompression, dwRedMask, dwGreenMask, dwBlueMask, dwWidth, dwHeight, dwDCICaps, dwBitCount, lplpSurface)
// hdc : HDC -> "pointer"
// dwCompression : DWORD -> "u32"
// dwRedMask : DWORD -> "u32"
// dwGreenMask : DWORD -> "u32"
// dwBlueMask : DWORD -> "u32"
// dwWidth : DWORD -> "u32"
// dwHeight : DWORD -> "u32"
// dwDCICaps : DWORD -> "u32"
// dwBitCount : DWORD -> "u32"
// lplpSurface : DCIOFFSCREEN** in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t DCICreateOffscreen(
void* hdc,
uint32_t dwCompression,
uint32_t dwRedMask,
uint32_t dwGreenMask,
uint32_t dwBlueMask,
uint32_t dwWidth,
uint32_t dwHeight,
uint32_t dwDCICaps,
uint32_t dwBitCount,
void* lplpSurface);
C, "DCIMAN32.dll");
// $ffi->DCICreateOffscreen(hdc, dwCompression, dwRedMask, dwGreenMask, dwBlueMask, dwWidth, dwHeight, dwDCICaps, dwBitCount, lplpSurface);
// hdc : HDC
// dwCompression : DWORD
// dwRedMask : DWORD
// dwGreenMask : DWORD
// dwBlueMask : DWORD
// dwWidth : DWORD
// dwHeight : DWORD
// dwDCICaps : DWORD
// dwBitCount : DWORD
// lplpSurface : DCIOFFSCREEN** 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 DCICreateOffscreen(
Pointer hdc, // HDC
int dwCompression, // DWORD
int dwRedMask, // DWORD
int dwGreenMask, // DWORD
int dwBlueMask, // DWORD
int dwWidth, // DWORD
int dwHeight, // DWORD
int dwDCICaps, // DWORD
int dwBitCount, // DWORD
Pointer lplpSurface // DCIOFFSCREEN** in/out
);
}@[Link("dciman32")]
lib LibDCIMAN32
fun DCICreateOffscreen = DCICreateOffscreen(
hdc : Void*, # HDC
dwCompression : UInt32, # DWORD
dwRedMask : UInt32, # DWORD
dwGreenMask : UInt32, # DWORD
dwBlueMask : UInt32, # DWORD
dwWidth : UInt32, # DWORD
dwHeight : UInt32, # DWORD
dwDCICaps : UInt32, # DWORD
dwBitCount : UInt32, # DWORD
lplpSurface : DCIOFFSCREEN** # DCIOFFSCREEN** in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DCICreateOffscreenNative = Int32 Function(Pointer<Void>, Uint32, Uint32, Uint32, Uint32, Uint32, Uint32, Uint32, Uint32, Pointer<Void>);
typedef DCICreateOffscreenDart = int Function(Pointer<Void>, int, int, int, int, int, int, int, int, Pointer<Void>);
final DCICreateOffscreen = DynamicLibrary.open('DCIMAN32.dll')
.lookupFunction<DCICreateOffscreenNative, DCICreateOffscreenDart>('DCICreateOffscreen');
// hdc : HDC -> Pointer<Void>
// dwCompression : DWORD -> Uint32
// dwRedMask : DWORD -> Uint32
// dwGreenMask : DWORD -> Uint32
// dwBlueMask : DWORD -> Uint32
// dwWidth : DWORD -> Uint32
// dwHeight : DWORD -> Uint32
// dwDCICaps : DWORD -> Uint32
// dwBitCount : DWORD -> Uint32
// lplpSurface : DCIOFFSCREEN** in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DCICreateOffscreen(
hdc: THandle; // HDC
dwCompression: DWORD; // DWORD
dwRedMask: DWORD; // DWORD
dwGreenMask: DWORD; // DWORD
dwBlueMask: DWORD; // DWORD
dwWidth: DWORD; // DWORD
dwHeight: DWORD; // DWORD
dwDCICaps: DWORD; // DWORD
dwBitCount: DWORD; // DWORD
lplpSurface: Pointer // DCIOFFSCREEN** in/out
): Integer; stdcall;
external 'DCIMAN32.dll' name 'DCICreateOffscreen';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DCICreateOffscreen"
c_DCICreateOffscreen :: Ptr () -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Ptr () -> IO Int32
-- hdc : HDC -> Ptr ()
-- dwCompression : DWORD -> Word32
-- dwRedMask : DWORD -> Word32
-- dwGreenMask : DWORD -> Word32
-- dwBlueMask : DWORD -> Word32
-- dwWidth : DWORD -> Word32
-- dwHeight : DWORD -> Word32
-- dwDCICaps : DWORD -> Word32
-- dwBitCount : DWORD -> Word32
-- lplpSurface : DCIOFFSCREEN** in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let dcicreateoffscreen =
foreign "DCICreateOffscreen"
((ptr void) @-> uint32_t @-> uint32_t @-> uint32_t @-> uint32_t @-> uint32_t @-> uint32_t @-> uint32_t @-> uint32_t @-> (ptr void) @-> returning int32_t)
(* hdc : HDC -> (ptr void) *)
(* dwCompression : DWORD -> uint32_t *)
(* dwRedMask : DWORD -> uint32_t *)
(* dwGreenMask : DWORD -> uint32_t *)
(* dwBlueMask : DWORD -> uint32_t *)
(* dwWidth : DWORD -> uint32_t *)
(* dwHeight : DWORD -> uint32_t *)
(* dwDCICaps : DWORD -> uint32_t *)
(* dwBitCount : DWORD -> uint32_t *)
(* lplpSurface : DCIOFFSCREEN** 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 ("DCICreateOffscreen" dcicreate-offscreen :convention :stdcall) :int32
(hdc :pointer) ; HDC
(dw-compression :uint32) ; DWORD
(dw-red-mask :uint32) ; DWORD
(dw-green-mask :uint32) ; DWORD
(dw-blue-mask :uint32) ; DWORD
(dw-width :uint32) ; DWORD
(dw-height :uint32) ; DWORD
(dw-dcicaps :uint32) ; DWORD
(dw-bit-count :uint32) ; DWORD
(lplp-surface :pointer)) ; DCIOFFSCREEN** in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DCICreateOffscreen = Win32::API::More->new('DCIMAN32',
'int DCICreateOffscreen(HANDLE hdc, DWORD dwCompression, DWORD dwRedMask, DWORD dwGreenMask, DWORD dwBlueMask, DWORD dwWidth, DWORD dwHeight, DWORD dwDCICaps, DWORD dwBitCount, LPVOID lplpSurface)');
# my $ret = $DCICreateOffscreen->Call($hdc, $dwCompression, $dwRedMask, $dwGreenMask, $dwBlueMask, $dwWidth, $dwHeight, $dwDCICaps, $dwBitCount, $lplpSurface);
# hdc : HDC -> HANDLE
# dwCompression : DWORD -> DWORD
# dwRedMask : DWORD -> DWORD
# dwGreenMask : DWORD -> DWORD
# dwBlueMask : DWORD -> DWORD
# dwWidth : DWORD -> DWORD
# dwHeight : DWORD -> DWORD
# dwDCICaps : DWORD -> DWORD
# dwBitCount : DWORD -> DWORD
# lplpSurface : DCIOFFSCREEN** in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型