Win32 API 日本語リファレンス
ホームGraphics.Gdi › DrawEscape

DrawEscape

関数
ビデオ表示用にドライバへ描画エスケープを送る。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

INT DrawEscape(
    HDC hdc,
    INT iEscape,
    INT cjIn,
    LPCSTR lpIn   // optional
);

パラメーター

名前方向説明
hdcHDCin指定したビデオディスプレイの DC へのハンドルです。
iEscapeINTin実行するエスケープ関数です。
cjInINTinlpszInData パラメーターが指すデータのバイト数です。
lpInLPCSTRinoptional指定したエスケープに必要な入力構造体へのポインターです。

戻り値の型: INT

公式ドキュメント

DrawEscape 関数は、グラフィックスデバイスインターフェイス (GDI) から直接利用できない、指定したビデオディスプレイの描画機能を提供します。

戻り値

関数が成功した場合、戻り値は 0 より大きくなります。ただし、実装の有無のみを確認する QUERYESCSUPPORT 描画エスケープは例外です。

エスケープが実装されていない場合、戻り値は 0 になります。

エラーが発生した場合、戻り値は 0 より小さくなります。

解説(Remarks)

アプリケーションが DrawEscape 関数を呼び出すと、cbInput および lpszInData で識別されるデータが、指定したディスプレイドライバーに直接渡されます。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

INT DrawEscape(
    HDC hdc,
    INT iEscape,
    INT cjIn,
    LPCSTR lpIn   // optional
);
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern int DrawEscape(
    IntPtr hdc,   // HDC
    int iEscape,   // INT
    int cjIn,   // INT
    [MarshalAs(UnmanagedType.LPStr)] string lpIn   // LPCSTR optional
);
<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function DrawEscape(
    hdc As IntPtr,   ' HDC
    iEscape As Integer,   ' INT
    cjIn As Integer,   ' INT
    <MarshalAs(UnmanagedType.LPStr)> lpIn As String   ' LPCSTR optional
) As Integer
End Function
' hdc : HDC
' iEscape : INT
' cjIn : INT
' lpIn : LPCSTR optional
Declare PtrSafe Function DrawEscape Lib "gdi32" ( _
    ByVal hdc As LongPtr, _
    ByVal iEscape As Long, _
    ByVal cjIn As Long, _
    ByVal lpIn As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DrawEscape = ctypes.windll.gdi32.DrawEscape
DrawEscape.restype = ctypes.c_int
DrawEscape.argtypes = [
    wintypes.HANDLE,  # hdc : HDC
    ctypes.c_int,  # iEscape : INT
    ctypes.c_int,  # cjIn : INT
    wintypes.LPCSTR,  # lpIn : LPCSTR optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GDI32.dll')
DrawEscape = Fiddle::Function.new(
  lib['DrawEscape'],
  [
    Fiddle::TYPE_VOIDP,  # hdc : HDC
    Fiddle::TYPE_INT,  # iEscape : INT
    Fiddle::TYPE_INT,  # cjIn : INT
    Fiddle::TYPE_VOIDP,  # lpIn : LPCSTR optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "gdi32")]
extern "system" {
    fn DrawEscape(
        hdc: *mut core::ffi::c_void,  // HDC
        iEscape: i32,  // INT
        cjIn: i32,  // INT
        lpIn: *const u8  // LPCSTR optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("GDI32.dll")]
public static extern int DrawEscape(IntPtr hdc, int iEscape, int cjIn, [MarshalAs(UnmanagedType.LPStr)] string lpIn);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_DrawEscape' -Namespace Win32 -PassThru
# $api::DrawEscape(hdc, iEscape, cjIn, lpIn)
#uselib "GDI32.dll"
#func global DrawEscape "DrawEscape" sptr, sptr, sptr, sptr
; DrawEscape hdc, iEscape, cjIn, lpIn   ; 戻り値は stat
; hdc : HDC -> "sptr"
; iEscape : INT -> "sptr"
; cjIn : INT -> "sptr"
; lpIn : LPCSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "GDI32.dll"
#cfunc global DrawEscape "DrawEscape" sptr, int, int, str
; res = DrawEscape(hdc, iEscape, cjIn, lpIn)
; hdc : HDC -> "sptr"
; iEscape : INT -> "int"
; cjIn : INT -> "int"
; lpIn : LPCSTR optional -> "str"
; INT DrawEscape(HDC hdc, INT iEscape, INT cjIn, LPCSTR lpIn)
#uselib "GDI32.dll"
#cfunc global DrawEscape "DrawEscape" intptr, int, int, str
; res = DrawEscape(hdc, iEscape, cjIn, lpIn)
; hdc : HDC -> "intptr"
; iEscape : INT -> "int"
; cjIn : INT -> "int"
; lpIn : LPCSTR optional -> "str"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procDrawEscape = gdi32.NewProc("DrawEscape")
)

// hdc (HDC), iEscape (INT), cjIn (INT), lpIn (LPCSTR optional)
r1, _, err := procDrawEscape.Call(
	uintptr(hdc),
	uintptr(iEscape),
	uintptr(cjIn),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(lpIn))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function DrawEscape(
  hdc: THandle;   // HDC
  iEscape: Integer;   // INT
  cjIn: Integer;   // INT
  lpIn: PAnsiChar   // LPCSTR optional
): Integer; stdcall;
  external 'GDI32.dll' name 'DrawEscape';
result := DllCall("GDI32\DrawEscape"
    , "Ptr", hdc   ; HDC
    , "Int", iEscape   ; INT
    , "Int", cjIn   ; INT
    , "AStr", lpIn   ; LPCSTR optional
    , "Int")   ; return: INT
●DrawEscape(hdc, iEscape, cjIn, lpIn) = DLL("GDI32.dll", "int DrawEscape(void*, int, int, char*)")
# 呼び出し: DrawEscape(hdc, iEscape, cjIn, lpIn)
# hdc : HDC -> "void*"
# iEscape : INT -> "int"
# cjIn : INT -> "int"
# lpIn : LPCSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef DrawEscapeNative = Int32 Function(Pointer<Void>, Int32, Int32, Pointer<Utf8>);
typedef DrawEscapeDart = int Function(Pointer<Void>, int, int, Pointer<Utf8>);
final DrawEscape = DynamicLibrary.open('GDI32.dll')
    .lookupFunction<DrawEscapeNative, DrawEscapeDart>('DrawEscape');
// hdc : HDC -> Pointer<Void>
// iEscape : INT -> Int32
// cjIn : INT -> Int32
// lpIn : LPCSTR optional -> Pointer<Utf8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function DrawEscape(
  hdc: THandle;   // HDC
  iEscape: Integer;   // INT
  cjIn: Integer;   // INT
  lpIn: PAnsiChar   // LPCSTR optional
): Integer; stdcall;
  external 'GDI32.dll' name 'DrawEscape';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "DrawEscape"
  c_DrawEscape :: Ptr () -> Int32 -> Int32 -> CString -> IO Int32
-- hdc : HDC -> Ptr ()
-- iEscape : INT -> Int32
-- cjIn : INT -> Int32
-- lpIn : LPCSTR optional -> CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let drawescape =
  foreign "DrawEscape"
    ((ptr void) @-> int32_t @-> int32_t @-> string @-> returning int32_t)
(* hdc : HDC -> (ptr void) *)
(* iEscape : INT -> int32_t *)
(* cjIn : INT -> int32_t *)
(* lpIn : LPCSTR optional -> string *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library gdi32 (t "GDI32.dll"))
(cffi:use-foreign-library gdi32)

(cffi:defcfun ("DrawEscape" draw-escape :convention :stdcall) :int32
  (hdc :pointer)   ; HDC
  (i-escape :int32)   ; INT
  (cj-in :int32)   ; INT
  (lp-in :string))   ; LPCSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $DrawEscape = Win32::API::More->new('GDI32',
    'int DrawEscape(HANDLE hdc, int iEscape, int cjIn, LPCSTR lpIn)');
# my $ret = $DrawEscape->Call($hdc, $iEscape, $cjIn, $lpIn);
# hdc : HDC -> HANDLE
# iEscape : INT -> int
# cjIn : INT -> int
# lpIn : LPCSTR optional -> LPCSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。